Commit 8a278994 authored by Lee Howes's avatar Lee Howes Committed by Facebook Github Bot

Rename hazptr DEBUG_PRINT macro to HAZPTR_DEBUG_PRINT to avoid name clashes...

Rename hazptr DEBUG_PRINT macro to HAZPTR_DEBUG_PRINT to avoid name clashes with other uses in code.

Reviewed By: yfeldblum, magedm

Differential Revision: D6863117

fbshipit-source-id: 1626eacafbdddcfdaf181b2a5d0f6e216425b1ff
parent 20260a99
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define HAZPTR_DEBUG false #define HAZPTR_DEBUG false
#endif #endif
#define DEBUG_PRINT(...) \ #define HAZPTR_DEBUG_PRINT(...) \
do { \ do { \
if (HAZPTR_DEBUG) { \ if (HAZPTR_DEBUG) { \
VLOG(2) << __func__ << " --- " << __VA_ARGS__; \ VLOG(2) << __func__ << " --- " << __VA_ARGS__; \
......
...@@ -27,11 +27,11 @@ class LockFreeLIFO { ...@@ -27,11 +27,11 @@ class LockFreeLIFO {
friend LockFreeLIFO; friend LockFreeLIFO;
public: public:
~Node() { ~Node() {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
} }
private: private:
Node(T v, Node* n) : value_(v), next_(n) { Node(T v, Node* n) : value_(v), next_(n) {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
} }
T value_; T value_;
Node* next_; Node* next_;
...@@ -39,15 +39,15 @@ class LockFreeLIFO { ...@@ -39,15 +39,15 @@ class LockFreeLIFO {
public: public:
LockFreeLIFO() { LockFreeLIFO() {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
} }
~LockFreeLIFO() { ~LockFreeLIFO() {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
} }
void push(T val) { void push(T val) {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
auto pnode = new Node(val, head_.load()); auto pnode = new Node(val, head_.load());
while (!head_.compare_exchange_weak(pnode->next_, pnode)) { while (!head_.compare_exchange_weak(pnode->next_, pnode)) {
; ;
...@@ -55,7 +55,7 @@ class LockFreeLIFO { ...@@ -55,7 +55,7 @@ class LockFreeLIFO {
} }
bool pop(T& val) { bool pop(T& val) {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
hazptr_holder hptr; hazptr_holder hptr;
Node* pnode = head_.load(); Node* pnode = head_.load();
do { do {
......
...@@ -65,11 +65,11 @@ class MWMRListSet { ...@@ -65,11 +65,11 @@ class MWMRListSet {
public: public:
explicit Node(T e) : elem_(e) { explicit Node(T e) : elem_(e) {
DEBUG_PRINT(this << " " << e); HAZPTR_DEBUG_PRINT(this << " " << e);
} }
~Node() { ~Node() {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
auto next = getPtr(next_.load(std::memory_order_relaxed)); auto next = getPtr(next_.load(std::memory_order_relaxed));
if (next) { if (next) {
next->release(); next->release();
......
...@@ -32,7 +32,7 @@ class SWMRListSet { ...@@ -32,7 +32,7 @@ class SWMRListSet {
template <typename Node> template <typename Node>
struct Reclaimer { struct Reclaimer {
void operator()(Node* p) { void operator()(Node* p) {
DEBUG_PRINT(p << " " << sizeof(Node)); HAZPTR_DEBUG_PRINT(p << " " << sizeof(Node));
delete p; delete p;
} }
}; };
...@@ -43,12 +43,12 @@ class SWMRListSet { ...@@ -43,12 +43,12 @@ class SWMRListSet {
std::atomic<Node*> next_; std::atomic<Node*> next_;
Node(T e, Node* n) : elem_(e), next_(n) { Node(T e, Node* n) : elem_(e), next_(n) {
DEBUG_PRINT(this << " " << e << " " << n); HAZPTR_DEBUG_PRINT(this << " " << e << " " << n);
} }
public: public:
~Node() { ~Node() {
DEBUG_PRINT(this); HAZPTR_DEBUG_PRINT(this);
} }
}; };
......
...@@ -30,10 +30,17 @@ class WideCAS { ...@@ -30,10 +30,17 @@ class WideCAS {
class Node : public hazptr_obj_base<Node> { class Node : public hazptr_obj_base<Node> {
friend WideCAS; friend WideCAS;
T val_; T val_;
Node() : val_(T()) { DEBUG_PRINT(this << " " << val_); } Node() : val_(T()) {
explicit Node(T v) : val_(v) { DEBUG_PRINT(this << " " << v); } HAZPTR_DEBUG_PRINT(this << " " << val_);
}
explicit Node(T v) : val_(v) {
HAZPTR_DEBUG_PRINT(this << " " << v);
}
public: public:
~Node() { DEBUG_PRINT(this); } ~Node() {
HAZPTR_DEBUG_PRINT(this);
}
}; };
std::atomic<Node*> p_ = {new Node()}; std::atomic<Node*> p_ = {new Node()};
...@@ -41,12 +48,12 @@ class WideCAS { ...@@ -41,12 +48,12 @@ class WideCAS {
public: public:
WideCAS() = default; WideCAS() = default;
~WideCAS() { ~WideCAS() {
DEBUG_PRINT(this << " " << p_.load()); HAZPTR_DEBUG_PRINT(this << " " << p_.load());
delete p_.load(); delete p_.load();
} }
bool cas(T& u, T& v) { bool cas(T& u, T& v) {
DEBUG_PRINT(this << " " << u << " " << v); HAZPTR_DEBUG_PRINT(this << " " << u << " " << v);
Node* n = new Node(v); Node* n = new Node(v);
hazptr_holder hptr; hazptr_holder hptr;
Node* p; Node* p;
...@@ -59,7 +66,7 @@ class WideCAS { ...@@ -59,7 +66,7 @@ class WideCAS {
} while (true); } while (true);
hptr.reset(); hptr.reset();
p->retire(); p->retire();
DEBUG_PRINT(this << " " << p << " " << u << " " << n << " " << v); HAZPTR_DEBUG_PRINT(this << " " << p << " " << u << " " << n << " " << v);
return true; return true;
} }
}; };
......
This diff is collapsed.
...@@ -23,18 +23,18 @@ namespace { ...@@ -23,18 +23,18 @@ namespace {
memory_resource** default_mr_ptr() { memory_resource** default_mr_ptr() {
/* library-local */ static memory_resource* default_mr = /* library-local */ static memory_resource* default_mr =
new_delete_resource(); new_delete_resource();
DEBUG_PRINT(&default_mr << " " << default_mr); HAZPTR_DEBUG_PRINT(&default_mr << " " << default_mr);
return &default_mr; return &default_mr;
} }
} // namespace } // namespace
memory_resource* get_default_resource() { memory_resource* get_default_resource() {
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
return *default_mr_ptr(); return *default_mr_ptr();
} }
void set_default_resource(memory_resource* mr) { void set_default_resource(memory_resource* mr) {
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
*default_mr_ptr() = mr; *default_mr_ptr() = mr;
} }
...@@ -45,7 +45,7 @@ memory_resource* new_delete_resource() { ...@@ -45,7 +45,7 @@ memory_resource* new_delete_resource() {
override { override {
(void)alignment; (void)alignment;
void* p = static_cast<void*>(new char[bytes]); void* p = static_cast<void*>(new char[bytes]);
DEBUG_PRINT(this << " " << p << " " << bytes); HAZPTR_DEBUG_PRINT(this << " " << p << " " << bytes);
return p; return p;
} }
void deallocate( void deallocate(
...@@ -54,7 +54,7 @@ memory_resource* new_delete_resource() { ...@@ -54,7 +54,7 @@ memory_resource* new_delete_resource() {
const size_t alignment = max_align_v) override { const size_t alignment = max_align_v) override {
(void)alignment; (void)alignment;
(void)bytes; (void)bytes;
DEBUG_PRINT(p << " " << bytes); HAZPTR_DEBUG_PRINT(p << " " << bytes);
delete[] static_cast<char*>(p); delete[] static_cast<char*>(p);
} }
}; };
......
...@@ -40,29 +40,29 @@ using namespace folly::hazptr; ...@@ -40,29 +40,29 @@ using namespace folly::hazptr;
class HazptrTest : public testing::Test { class HazptrTest : public testing::Test {
public: public:
HazptrTest() : Test() { HazptrTest() : Test() {
DEBUG_PRINT("========== start of test scope"); HAZPTR_DEBUG_PRINT("========== start of test scope");
} }
~HazptrTest() override { ~HazptrTest() override {
DEBUG_PRINT("========== end of test scope"); HAZPTR_DEBUG_PRINT("========== end of test scope");
} }
}; };
TEST_F(HazptrTest, Test1) { TEST_F(HazptrTest, Test1) {
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
Node1* node0 = (Node1*)malloc(sizeof(Node1)); Node1* node0 = (Node1*)malloc(sizeof(Node1));
node0 = new (node0) Node1; node0 = new (node0) Node1;
DEBUG_PRINT("=== malloc node0 " << node0 << " " << sizeof(*node0)); HAZPTR_DEBUG_PRINT("=== malloc node0 " << node0 << " " << sizeof(*node0));
Node1* node1 = (Node1*)malloc(sizeof(Node1)); Node1* node1 = (Node1*)malloc(sizeof(Node1));
node1 = new (node1) Node1; node1 = new (node1) Node1;
DEBUG_PRINT("=== malloc node1 " << node1 << " " << sizeof(*node1)); HAZPTR_DEBUG_PRINT("=== malloc node1 " << node1 << " " << sizeof(*node1));
Node1* node2 = (Node1*)malloc(sizeof(Node1)); Node1* node2 = (Node1*)malloc(sizeof(Node1));
node2 = new (node2) Node1; node2 = new (node2) Node1;
DEBUG_PRINT("=== malloc node2 " << node2 << " " << sizeof(*node2)); HAZPTR_DEBUG_PRINT("=== malloc node2 " << node2 << " " << sizeof(*node2));
Node1* node3 = (Node1*)malloc(sizeof(Node1)); Node1* node3 = (Node1*)malloc(sizeof(Node1));
node3 = new (node3) Node1; node3 = new (node3) Node1;
DEBUG_PRINT("=== malloc node3 " << node3 << " " << sizeof(*node3)); HAZPTR_DEBUG_PRINT("=== malloc node3 " << node3 << " " << sizeof(*node3));
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
std::atomic<Node1*> shared0 = {node0}; std::atomic<Node1*> shared0 = {node0};
std::atomic<Node1*> shared1 = {node1}; std::atomic<Node1*> shared1 = {node1};
...@@ -70,24 +70,24 @@ TEST_F(HazptrTest, Test1) { ...@@ -70,24 +70,24 @@ TEST_F(HazptrTest, Test1) {
std::atomic<Node1*> shared3 = {node3}; std::atomic<Node1*> shared3 = {node3};
MyMemoryResource myMr; MyMemoryResource myMr;
DEBUG_PRINT("=== myMr " << &myMr); HAZPTR_DEBUG_PRINT("=== myMr " << &myMr);
hazptr_domain myDomain0; hazptr_domain myDomain0;
DEBUG_PRINT("=== myDomain0 " << &myDomain0); HAZPTR_DEBUG_PRINT("=== myDomain0 " << &myDomain0);
hazptr_domain myDomain1(&myMr); hazptr_domain myDomain1(&myMr);
DEBUG_PRINT("=== myDomain1 " << &myDomain1); HAZPTR_DEBUG_PRINT("=== myDomain1 " << &myDomain1);
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
DEBUG_PRINT("=== hptr0"); HAZPTR_DEBUG_PRINT("=== hptr0");
hazptr_holder hptr0; hazptr_holder hptr0;
DEBUG_PRINT("=== hptr1"); HAZPTR_DEBUG_PRINT("=== hptr1");
hazptr_holder hptr1(myDomain0); hazptr_holder hptr1(myDomain0);
DEBUG_PRINT("=== hptr2"); HAZPTR_DEBUG_PRINT("=== hptr2");
hazptr_holder hptr2(myDomain1); hazptr_holder hptr2(myDomain1);
DEBUG_PRINT("=== hptr3"); HAZPTR_DEBUG_PRINT("=== hptr3");
hazptr_holder hptr3; hazptr_holder hptr3;
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
Node1* n0 = shared0.load(); Node1* n0 = shared0.load();
Node1* n1 = shared1.load(); Node1* n1 = shared1.load();
...@@ -103,32 +103,32 @@ TEST_F(HazptrTest, Test1) { ...@@ -103,32 +103,32 @@ TEST_F(HazptrTest, Test1) {
swap(hptr1, hptr2); swap(hptr1, hptr2);
hptr3.reset(); hptr3.reset();
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
DEBUG_PRINT("=== retire n0 " << n0); HAZPTR_DEBUG_PRINT("=== retire n0 " << n0);
n0->retire(); n0->retire();
DEBUG_PRINT("=== retire n1 " << n1); HAZPTR_DEBUG_PRINT("=== retire n1 " << n1);
n1->retire(default_hazptr_domain()); n1->retire(default_hazptr_domain());
DEBUG_PRINT("=== retire n2 " << n2); HAZPTR_DEBUG_PRINT("=== retire n2 " << n2);
n2->retire(myDomain0); n2->retire(myDomain0);
DEBUG_PRINT("=== retire n3 " << n3); HAZPTR_DEBUG_PRINT("=== retire n3 " << n3);
n3->retire(myDomain1); n3->retire(myDomain1);
} }
TEST_F(HazptrTest, Test2) { TEST_F(HazptrTest, Test2) {
Node2* node0 = new Node2; Node2* node0 = new Node2;
DEBUG_PRINT("=== new node0 " << node0 << " " << sizeof(*node0)); HAZPTR_DEBUG_PRINT("=== new node0 " << node0 << " " << sizeof(*node0));
Node2* node1 = (Node2*)malloc(sizeof(Node2)); Node2* node1 = (Node2*)malloc(sizeof(Node2));
node1 = new (node1) Node2; node1 = new (node1) Node2;
DEBUG_PRINT("=== malloc node1 " << node1 << " " << sizeof(*node1)); HAZPTR_DEBUG_PRINT("=== malloc node1 " << node1 << " " << sizeof(*node1));
Node2* node2 = (Node2*)malloc(sizeof(Node2)); Node2* node2 = (Node2*)malloc(sizeof(Node2));
node2 = new (node2) Node2; node2 = new (node2) Node2;
DEBUG_PRINT("=== malloc node2 " << node2 << " " << sizeof(*node2)); HAZPTR_DEBUG_PRINT("=== malloc node2 " << node2 << " " << sizeof(*node2));
Node2* node3 = (Node2*)malloc(sizeof(Node2)); Node2* node3 = (Node2*)malloc(sizeof(Node2));
node3 = new (node3) Node2; node3 = new (node3) Node2;
DEBUG_PRINT("=== malloc node3 " << node3 << " " << sizeof(*node3)); HAZPTR_DEBUG_PRINT("=== malloc node3 " << node3 << " " << sizeof(*node3));
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
std::atomic<Node2*> shared0 = {node0}; std::atomic<Node2*> shared0 = {node0};
std::atomic<Node2*> shared1 = {node1}; std::atomic<Node2*> shared1 = {node1};
...@@ -136,24 +136,24 @@ TEST_F(HazptrTest, Test2) { ...@@ -136,24 +136,24 @@ TEST_F(HazptrTest, Test2) {
std::atomic<Node2*> shared3 = {node3}; std::atomic<Node2*> shared3 = {node3};
MineMemoryResource mineMr; MineMemoryResource mineMr;
DEBUG_PRINT("=== mineMr " << &mineMr); HAZPTR_DEBUG_PRINT("=== mineMr " << &mineMr);
hazptr_domain mineDomain0; hazptr_domain mineDomain0;
DEBUG_PRINT("=== mineDomain0 " << &mineDomain0); HAZPTR_DEBUG_PRINT("=== mineDomain0 " << &mineDomain0);
hazptr_domain mineDomain1(&mineMr); hazptr_domain mineDomain1(&mineMr);
DEBUG_PRINT("=== mineDomain1 " << &mineDomain1); HAZPTR_DEBUG_PRINT("=== mineDomain1 " << &mineDomain1);
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
DEBUG_PRINT("=== hptr0"); HAZPTR_DEBUG_PRINT("=== hptr0");
hazptr_holder hptr0; hazptr_holder hptr0;
DEBUG_PRINT("=== hptr1"); HAZPTR_DEBUG_PRINT("=== hptr1");
hazptr_holder hptr1(mineDomain0); hazptr_holder hptr1(mineDomain0);
DEBUG_PRINT("=== hptr2"); HAZPTR_DEBUG_PRINT("=== hptr2");
hazptr_holder hptr2(mineDomain1); hazptr_holder hptr2(mineDomain1);
DEBUG_PRINT("=== hptr3"); HAZPTR_DEBUG_PRINT("=== hptr3");
hazptr_holder hptr3; hazptr_holder hptr3;
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
Node2* n0 = shared0.load(); Node2* n0 = shared0.load();
Node2* n1 = shared1.load(); Node2* n1 = shared1.load();
...@@ -168,15 +168,15 @@ TEST_F(HazptrTest, Test2) { ...@@ -168,15 +168,15 @@ TEST_F(HazptrTest, Test2) {
swap(hptr1, hptr2); swap(hptr1, hptr2);
hptr3.reset(); hptr3.reset();
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
DEBUG_PRINT("=== retire n0 " << n0); HAZPTR_DEBUG_PRINT("=== retire n0 " << n0);
n0->retire(default_hazptr_domain(), &mineReclaimFnDelete); n0->retire(default_hazptr_domain(), &mineReclaimFnDelete);
DEBUG_PRINT("=== retire n1 " << n1); HAZPTR_DEBUG_PRINT("=== retire n1 " << n1);
n1->retire(default_hazptr_domain(), &mineReclaimFnFree); n1->retire(default_hazptr_domain(), &mineReclaimFnFree);
DEBUG_PRINT("=== retire n2 " << n2); HAZPTR_DEBUG_PRINT("=== retire n2 " << n2);
n2->retire(mineDomain0, &mineReclaimFnFree); n2->retire(mineDomain0, &mineReclaimFnFree);
DEBUG_PRINT("=== retire n3 " << n3); HAZPTR_DEBUG_PRINT("=== retire n3 " << n3);
n3->retire(mineDomain1, &mineReclaimFnFree); n3->retire(mineDomain1, &mineReclaimFnFree);
} }
...@@ -184,7 +184,7 @@ TEST_F(HazptrTest, LIFO) { ...@@ -184,7 +184,7 @@ TEST_F(HazptrTest, LIFO) {
using T = uint32_t; using T = uint32_t;
CHECK_GT(FLAGS_num_threads, 0); CHECK_GT(FLAGS_num_threads, 0);
for (int i = 0; i < FLAGS_num_reps; ++i) { for (int i = 0; i < FLAGS_num_reps; ++i) {
DEBUG_PRINT("========== start of rep scope"); HAZPTR_DEBUG_PRINT("========== start of rep scope");
LockFreeLIFO<T> s; LockFreeLIFO<T> s;
std::vector<std::thread> threads(FLAGS_num_threads); std::vector<std::thread> threads(FLAGS_num_threads);
for (int tid = 0; tid < FLAGS_num_threads; ++tid) { for (int tid = 0; tid < FLAGS_num_threads; ++tid) {
...@@ -201,7 +201,7 @@ TEST_F(HazptrTest, LIFO) { ...@@ -201,7 +201,7 @@ TEST_F(HazptrTest, LIFO) {
for (auto& t : threads) { for (auto& t : threads) {
t.join(); t.join();
} }
DEBUG_PRINT("========== end of rep scope"); HAZPTR_DEBUG_PRINT("========== end of rep scope");
} }
} }
...@@ -210,7 +210,7 @@ TEST_F(HazptrTest, SWMRLIST) { ...@@ -210,7 +210,7 @@ TEST_F(HazptrTest, SWMRLIST) {
CHECK_GT(FLAGS_num_threads, 0); CHECK_GT(FLAGS_num_threads, 0);
for (int i = 0; i < FLAGS_num_reps; ++i) { for (int i = 0; i < FLAGS_num_reps; ++i) {
DEBUG_PRINT("========== start of rep scope"); HAZPTR_DEBUG_PRINT("========== start of rep scope");
SWMRListSet<T> s; SWMRListSet<T> s;
std::vector<std::thread> threads(FLAGS_num_threads); std::vector<std::thread> threads(FLAGS_num_threads);
for (int tid = 0; tid < FLAGS_num_threads; ++tid) { for (int tid = 0; tid < FLAGS_num_threads; ++tid) {
...@@ -229,7 +229,7 @@ TEST_F(HazptrTest, SWMRLIST) { ...@@ -229,7 +229,7 @@ TEST_F(HazptrTest, SWMRLIST) {
for (auto& t : threads) { for (auto& t : threads) {
t.join(); t.join();
} }
DEBUG_PRINT("========== end of rep scope"); HAZPTR_DEBUG_PRINT("========== end of rep scope");
} }
} }
...@@ -238,7 +238,7 @@ TEST_F(HazptrTest, MWMRSet) { ...@@ -238,7 +238,7 @@ TEST_F(HazptrTest, MWMRSet) {
CHECK_GT(FLAGS_num_threads, 0); CHECK_GT(FLAGS_num_threads, 0);
for (int i = 0; i < FLAGS_num_reps; ++i) { for (int i = 0; i < FLAGS_num_reps; ++i) {
DEBUG_PRINT("========== start of rep scope"); HAZPTR_DEBUG_PRINT("========== start of rep scope");
MWMRListSet<T> s; MWMRListSet<T> s;
std::vector<std::thread> threads(FLAGS_num_threads); std::vector<std::thread> threads(FLAGS_num_threads);
for (int tid = 0; tid < FLAGS_num_threads; ++tid) { for (int tid = 0; tid < FLAGS_num_threads; ++tid) {
...@@ -259,7 +259,7 @@ TEST_F(HazptrTest, MWMRSet) { ...@@ -259,7 +259,7 @@ TEST_F(HazptrTest, MWMRSet) {
for (auto& t : threads) { for (auto& t : threads) {
t.join(); t.join();
} }
DEBUG_PRINT("========== end of rep scope"); HAZPTR_DEBUG_PRINT("========== end of rep scope");
} }
} }
...@@ -286,7 +286,7 @@ TEST_F(HazptrTest, WIDECAS) { ...@@ -286,7 +286,7 @@ TEST_F(HazptrTest, WIDECAS) {
TEST_F(HazptrTest, VirtualTest) { TEST_F(HazptrTest, VirtualTest) {
struct Thing : public hazptr_obj_base<Thing> { struct Thing : public hazptr_obj_base<Thing> {
virtual ~Thing() { virtual ~Thing() {
DEBUG_PRINT("this: " << this << " &a: " << &a << " a: " << a); HAZPTR_DEBUG_PRINT("this: " << this << " &a: " << &a << " a: " << a);
} }
int a; int a;
}; };
...@@ -308,7 +308,8 @@ void destructionTest(hazptr_domain& domain) { ...@@ -308,7 +308,8 @@ void destructionTest(hazptr_domain& domain) {
int val; int val;
Thing(int v, Thing* n, hazptr_domain* d) : next(n), domain(d), val(v) {} Thing(int v, Thing* n, hazptr_domain* d) : next(n), domain(d), val(v) {}
~Thing() { ~Thing() {
DEBUG_PRINT("this: " << this << " val: " << val << " next: " << next); HAZPTR_DEBUG_PRINT(
"this: " << this << " val: " << val << " next: " << next);
if (next) { if (next) {
next->retire(*domain); next->retire(*domain);
} }
...@@ -415,11 +416,11 @@ struct Foo : hazptr_obj_base_refcounted<Foo> { ...@@ -415,11 +416,11 @@ struct Foo : hazptr_obj_base_refcounted<Foo> {
bool marked_; bool marked_;
Foo* next_; Foo* next_;
Foo(int v, Foo* n) : val_(v), marked_(false), next_(n) { Foo(int v, Foo* n) : val_(v), marked_(false), next_(n) {
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
++constructed; ++constructed;
} }
~Foo() { ~Foo() {
DEBUG_PRINT(""); HAZPTR_DEBUG_PRINT("");
++destroyed; ++destroyed;
if (marked_) { if (marked_) {
return; return;
...@@ -530,11 +531,11 @@ TEST_F(HazptrTest, mt_refcount) { ...@@ -530,11 +531,11 @@ TEST_F(HazptrTest, mt_refcount) {
for (auto q = p; q; q = q->next_) { for (auto q = p; q; q = q->next_) {
q->retire(); q->retire();
} }
DEBUG_PRINT("Foo should not be destroyed"); HAZPTR_DEBUG_PRINT("Foo should not be destroyed");
CHECK_EQ(constructed.load(), num); CHECK_EQ(constructed.load(), num);
CHECK_EQ(destroyed.load(), 0); CHECK_EQ(destroyed.load(), 0);
DEBUG_PRINT("Foo may be destroyed after releasing the last reference"); HAZPTR_DEBUG_PRINT("Foo may be destroyed after releasing the last reference");
if (p->release_ref()) { if (p->release_ref()) {
delete p; delete p;
} }
......
...@@ -25,12 +25,12 @@ class MyMemoryResource : public memory_resource { ...@@ -25,12 +25,12 @@ class MyMemoryResource : public memory_resource {
public: public:
void* allocate(const size_t sz, const size_t /* align */) override { void* allocate(const size_t sz, const size_t /* align */) override {
void* p = malloc(sz); void* p = malloc(sz);
DEBUG_PRINT(p << " " << sz); HAZPTR_DEBUG_PRINT(p << " " << sz);
return p; return p;
} }
void deallocate(void* p, const size_t sz, const size_t /* align */) override { void deallocate(void* p, const size_t sz, const size_t /* align */) override {
DEBUG_PRINT(p << " " << sz); HAZPTR_DEBUG_PRINT(p << " " << sz);
free(p); free(p);
} }
}; };
...@@ -38,7 +38,7 @@ class MyMemoryResource : public memory_resource { ...@@ -38,7 +38,7 @@ class MyMemoryResource : public memory_resource {
template <typename Node1> template <typename Node1>
struct MyReclaimerFree { struct MyReclaimerFree {
inline void operator()(Node1* p) { inline void operator()(Node1* p) {
DEBUG_PRINT(p << " " << sizeof(Node1)); HAZPTR_DEBUG_PRINT(p << " " << sizeof(Node1));
free(p); free(p);
} }
}; };
......
...@@ -25,12 +25,12 @@ class MineMemoryResource : public memory_resource { ...@@ -25,12 +25,12 @@ class MineMemoryResource : public memory_resource {
public: public:
void* allocate(const size_t sz, const size_t /* align */) override { void* allocate(const size_t sz, const size_t /* align */) override {
void* p = malloc(sz); void* p = malloc(sz);
DEBUG_PRINT(p << " " << sz); HAZPTR_DEBUG_PRINT(p << " " << sz);
return p; return p;
} }
void deallocate(void* p, const size_t sz, const size_t /* align */) override { void deallocate(void* p, const size_t sz, const size_t /* align */) override {
DEBUG_PRINT(p << " " << sz); HAZPTR_DEBUG_PRINT(p << " " << sz);
free(p); free(p);
} }
}; };
...@@ -40,12 +40,12 @@ class Node2 : public hazptr_obj_base<Node2, void (*)(Node2*)> { ...@@ -40,12 +40,12 @@ class Node2 : public hazptr_obj_base<Node2, void (*)(Node2*)> {
}; };
inline void mineReclaimFnFree(Node2* p) { inline void mineReclaimFnFree(Node2* p) {
DEBUG_PRINT(p << " " << sizeof(Node2)); HAZPTR_DEBUG_PRINT(p << " " << sizeof(Node2));
free(p); free(p);
} }
inline void mineReclaimFnDelete(Node2* p) { inline void mineReclaimFnDelete(Node2* p) {
DEBUG_PRINT(p << " " << sizeof(Node2)); HAZPTR_DEBUG_PRINT(p << " " << sizeof(Node2));
delete p; delete p;
} }
......
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