Commit d96d961f authored by Maged Michael's avatar Maged Michael Committed by Facebook GitHub Bot

hazptr_test: Fix test and microbenchmark

Summary:
Fix reclamation_without_calling_cleanup test to wait for the start of asynchronous reclamation which is done on a different thread.

Fix list_protect_all_bench. The node links in the list must be immutable since the List destructor retires each node in the list, whereas nodes with mutable links automatically unlink their children and retire them if a child's last link is unlinked.

Reviewed By: yfeldblum

Differential Revision: D31101932

fbshipit-source-id: 3afa4b07cd56e07eccab9be69bfe895e4f54aee8
parent a2792966
...@@ -223,7 +223,7 @@ struct List { ...@@ -223,7 +223,7 @@ struct List {
hazptr_local<1, Atom> hptr; hazptr_local<1, Atom> hptr;
return protect_all(val, hptr[0]); return protect_all(val, hptr[0]);
} }
}; // NodeRC }; // List
/** NodeAuto */ /** NodeAuto */
template <template <typename> class Atom = std::atomic> template <template <typename> class Atom = std::atomic>
...@@ -1288,6 +1288,8 @@ TEST(HazptrTest, reclamation_without_calling_cleanup) { ...@@ -1288,6 +1288,8 @@ TEST(HazptrTest, reclamation_without_calling_cleanup) {
for (auto& t : thr) { for (auto& t : thr) {
t.join(); t.join();
} }
while (c_.dtors() == 0)
/* Wait for asynchronous reclamation. */;
ASSERT_GT(c_.dtors(), 0); ASSERT_GT(c_.dtors(), 0);
} }
...@@ -1445,7 +1447,7 @@ uint64_t list_hoh_bench( ...@@ -1445,7 +1447,7 @@ uint64_t list_hoh_bench(
uint64_t list_protect_all_bench( uint64_t list_protect_all_bench(
std::string name, int nthreads, int size, bool provided = false) { std::string name, int nthreads, int size, bool provided = false) {
auto repFn = [&] { auto repFn = [&] {
List<NodeRC<true>> l(size); List<NodeRC<false>> l(size);
auto init = [] {}; auto init = [] {};
auto fn = [&](int tid) { auto fn = [&](int tid) {
if (provided) { if (provided) {
......
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