Refactors sequential misc test cases
[libcds.git] / test / stress / sequential / sequential-misc / rwlock_driver.cpp
index aee9463..ab9ca0a 100644 (file)
@@ -20,7 +20,6 @@ class RWLockTest : public cds_test::stress_fixture {
 protected:
   static size_t sum;
   static size_t x;
 protected:
   static size_t sum;
   static size_t x;
-  static RWLock *rwlock;
 
   static void SetUpTestCase() {
     cds_test::config const &cfg = get_config("SequentialMisc");
 
   static void SetUpTestCase() {
     cds_test::config const &cfg = get_config("SequentialMisc");
@@ -28,7 +27,7 @@ protected:
     GetConfig(RWLockPassCount);
   }
 
     GetConfig(RWLockPassCount);
   }
 
-  static void ReaderWriterThread(int write_percentage) {
+  static void ReaderWriterThread(RWLock *rwlock, int write_percentage) {
     for (size_t i = 0; i < s_nRWLockPassCount; i++) {
       if (rand(100) < write_percentage) {
         if (rwlock->read_can_lock()) {
     for (size_t i = 0; i < s_nRWLockPassCount; i++) {
       if (rand(100) < write_percentage) {
         if (rwlock->read_can_lock()) {
@@ -61,12 +60,11 @@ protected:
 
 size_t RWLockTest::x;
 size_t RWLockTest::sum;
 
 size_t RWLockTest::x;
 size_t RWLockTest::sum;
-RWLock *RWLockTest::rwlock;
 
 TEST_F(RWLockTest, ReadWriteLock) {
 
 TEST_F(RWLockTest, ReadWriteLock) {
-  rwlock = new RWLock();
+  std::unique_ptr<RWLock> rwlock(new RWLock());
   for (int write_percentage = 5; write_percentage < 40; write_percentage += 5) {
   for (int write_percentage = 5; write_percentage < 40; write_percentage += 5) {
-    ReaderWriterThread(write_percentage);
+    ReaderWriterThread(rwlock.get(), write_percentage);
   }
 }
 
   }
 }