Refactors sequential misc test cases
[libcds.git] / test / stress / sequential / sequential-misc / spinlock_driver.cpp
index bd2c42a39695f790c0a34e53bdb4604e7c17f65b..6dce8121dfe241c7f6071ba4e0b59bfefa5aca1c 100644 (file)
@@ -3,7 +3,7 @@
 #include <cds/gc/dhp.h>
 #include <cds/gc/hp.h>
 #include <cds/sync/spinlock.h>
-#include <cds/sync/ticket_lock.h>
+#include <cds/misc/ticket_lock.h>
 #include <cds_test/stress_test.h>
 #include <iostream>
 #include <iostream>
@@ -23,7 +23,7 @@ static size_t s_nSpinLockPassCount = 2500000000;
 static size_t s_nTicketLockPassCount = 4000000;
 
 #define TASK(lock_type, lock_ptr, pass_cnt)                                    \
-  static void Thread##lock_type() {                                            \
+  static void Thread##lock_type(lock_type *lock_ptr) {                         \
     for (size_t i = 0; i < pass_cnt; i++) {                                    \
       lock_ptr->lock();                                                        \
       x++;                                                                     \
@@ -33,9 +33,9 @@ static size_t s_nTicketLockPassCount = 4000000;
 
 #define LOCK_TEST(lock_type, lock_ptr, pass_cnt)                               \
   TEST_F(SpinLockTest, lock_type) {                                            \
-    lock_ptr = new lock_type();                                                \
+    std::unique_ptr<lock_type> lock_ptr(new lock_type());                      \
     x = 0;                                                                     \
-    Thread##lock_type();                                                       \
+    Thread##lock_type(lock_ptr.get());                                         \
   }
 
 class SpinLockTest : public cds_test::stress_fixture {