#include <folly/experimental/hazptr/debug.h>
#include <folly/experimental/hazptr/example/LockFreeLIFO.h>
+#include <folly/experimental/hazptr/example/MWMRSet.h>
#include <folly/experimental/hazptr/example/SWMRList.h>
#include <folly/experimental/hazptr/example/WideCAS.h>
#include <folly/experimental/hazptr/hazptr.h>
}
}
+TEST_F(HazptrTest, MWMRSet) {
+ using T = uint64_t;
+
+ CHECK_GT(FLAGS_num_threads, 0);
+ for (int i = 0; i < FLAGS_num_reps; ++i) {
+ DEBUG_PRINT("========== start of rep scope");
+ MWMRListSet<T> s;
+ std::vector<std::thread> threads(FLAGS_num_threads);
+ for (int tid = 0; tid < FLAGS_num_threads; ++tid) {
+ threads[tid] = std::thread([&s, tid]() {
+ for (int j = tid; j < FLAGS_num_ops; j += FLAGS_num_threads) {
+ s.contains(j);
+ s.add(j);
+ s.remove(j);
+ }
+ });
+ }
+ for (int j = 0; j < 10; ++j) {
+ s.add(j);
+ }
+ for (int j = 0; j < 10; ++j) {
+ s.remove(j);
+ }
+ for (auto& t : threads) {
+ t.join();
+ }
+ DEBUG_PRINT("========== end of rep scope");
+ }
+}
+
TEST_F(HazptrTest, WIDECAS) {
WideCAS s;
std::string u = "";