Commit 20732849 authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

Back out "hazptr: Allow destruction of obj batch after default domain"

Summary: Original commit changeset: 6021479ab36c

Reviewed By: d4l3k

Differential Revision: D18535981

fbshipit-source-id: 4f9e5da29ed6d9bae04f29bcf273b41d39cc5754
parent 2ba9c401
...@@ -132,10 +132,6 @@ class hazptr_domain; ...@@ -132,10 +132,6 @@ class hazptr_domain;
template <template <typename> class Atom = std::atomic> template <template <typename> class Atom = std::atomic>
hazptr_domain<Atom>& default_hazptr_domain(); hazptr_domain<Atom>& default_hazptr_domain();
/** default_hazptr_domain_alive */
template <template <typename> class Atom = std::atomic>
bool& default_hazptr_domain_alive();
/** hazptr_domain_push_list */ /** hazptr_domain_push_list */
template <template <typename> class Atom = std::atomic> template <template <typename> class Atom = std::atomic>
void hazptr_domain_push_list( void hazptr_domain_push_list(
......
...@@ -133,26 +133,14 @@ class hazptr_domain { ...@@ -133,26 +133,14 @@ class hazptr_domain {
public: public:
/** Constructor */ /** Constructor */
hazptr_domain() { hazptr_domain() = default;
if (std::is_same<Atom<int>, std::atomic<int>>{} &&
this == &default_hazptr_domain<Atom>()) {
set_default_hazptr_domain_alive(true);
}
}
/** Destructor */ /** Destructor */
~hazptr_domain() { ~hazptr_domain() {
shutdown_ = true; shutdown_ = true;
reclaim_all_objects(); reclaim_all_objects();
free_hazptr_recs(); free_hazptr_recs();
if (!tagged_.empty()) { DCHECK(tagged_.empty());
auto head = tagged_.pop_all(RetiredList::kDontLock);
reclaim_list_transitive(head);
}
if (std::is_same<Atom<int>, std::atomic<int>>{} &&
this == &default_hazptr_domain<Atom>()) {
set_default_hazptr_domain_alive(false);
}
} }
hazptr_domain(const hazptr_domain&) = delete; hazptr_domain(const hazptr_domain&) = delete;
...@@ -595,10 +583,6 @@ class hazptr_domain { ...@@ -595,10 +583,6 @@ class hazptr_domain {
hcount_.fetch_add(1); hcount_.fetch_add(1);
return rec; return rec;
} }
void set_default_hazptr_domain_alive(bool b) {
default_hazptr_domain_alive<Atom>() = b;
}
}; // hazptr_domain }; // hazptr_domain
/** /**
...@@ -627,12 +611,6 @@ FOLLY_ALWAYS_INLINE hazptr_domain<Atom>& default_hazptr_domain() { ...@@ -627,12 +611,6 @@ FOLLY_ALWAYS_INLINE hazptr_domain<Atom>& default_hazptr_domain() {
return hazptr_default_domain_helper<Atom>::get(); return hazptr_default_domain_helper<Atom>::get();
} }
template <template <typename> class Atom>
bool& default_hazptr_domain_alive() {
static bool alive = false;
return alive;
}
/** hazptr_domain_push_retired: push a list of retired objects into a domain */ /** hazptr_domain_push_retired: push a list of retired objects into a domain */
template <template <typename> class Atom> template <template <typename> class Atom>
void hazptr_domain_push_retired( void hazptr_domain_push_retired(
......
...@@ -331,8 +331,7 @@ class hazptr_obj_batch { ...@@ -331,8 +331,7 @@ class hazptr_obj_batch {
Obj* obj = l.head(); Obj* obj = l.head();
reclaim_list(obj); reclaim_list(obj);
} }
if (pushed_to_domain_tagged_.load(std::memory_order_relaxed) && if (pushed_to_domain_tagged_.load(std::memory_order_relaxed)) {
default_hazptr_domain_alive<Atom>()) {
default_hazptr_domain<Atom>().cleanup_batch_tag(this); default_hazptr_domain<Atom>().cleanup_batch_tag(this);
} }
DCHECK(l_.empty()); DCHECK(l_.empty());
...@@ -360,7 +359,7 @@ class hazptr_obj_batch { ...@@ -360,7 +359,7 @@ class hazptr_obj_batch {
/** push_obj */ /** push_obj */
void push_obj(Obj* obj) { void push_obj(Obj* obj) {
if (active_ && default_hazptr_domain_alive<Atom>()) { if (active_) {
l_.push(obj); l_.push(obj);
inc_count(); inc_count();
check_threshold_push(); check_threshold_push();
...@@ -385,9 +384,6 @@ class hazptr_obj_batch { ...@@ -385,9 +384,6 @@ class hazptr_obj_batch {
/** check_threshold_push */ /** check_threshold_push */
void check_threshold_push() { void check_threshold_push() {
if (!default_hazptr_domain_alive<Atom>()) {
return;
}
auto c = count(); auto c = count();
while (c >= kThreshold) { while (c >= kThreshold) {
if (cas_count(c, 0)) { if (cas_count(c, 0)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment