-#include <folly/SmallLocks.h>
-#include <folly/RWSpinLock.h>
-#include <folly/SharedMutex.h>
-#include <folly/synchronization/Rcu.h>
-
-#include <gtest/gtest.h>
-
-#include <memory>
-
-namespace {
-
-// MicroLock
-const size_t kMicroLockPassCount = 2000000000;
-typedef folly::MicroLock MicroLock;
-
-// MicroSpinLock
-const size_t kMicroSpinLockPassCount = 1500000000;
-typedef folly::MicroSpinLock MicroSpinLock;
-
-// PicoSpinLock
-const size_t kPicoSpinLockPassCount = 2700000000;
-typedef folly::PicoSpinLock<size_t> PicoSpinLock;
-
-// SharedMutex
-const size_t kSharedMutexPassCount = 5000000;
-typedef folly::SharedMutexReadPriority SharedMutexReadPriority;
-typedef folly::SharedMutexWritePriority SharedMutexWritePriority;
-
-// RWSpinLock
-const size_t kRWSpinLockPassCount = 5000000;
-typedef folly::RWSpinLock RWSpinLock;
-
-// RWTicketSpinLock
-const size_t kRWTicketSpinLockPassCount = 5000000;
-typedef folly::RWTicketSpinLock32 RWTicketSpinLock32;
-typedef folly::RWTicketSpinLock64 RWTicketSpinLock64;
-
-// RCU
-const size_t kRcuSyncPassCount = 180000;
-const size_t kRcuNoSyncPassCount = 3500000;
-// Represent the RCU-protected data.
-struct RcuFoo {
- size_t f1;
- size_t f2;
-};
-
-}
+#include "sync_test.h"
+
+namespace folly_test {
+
+class FollySyncTest_Parallel: public cds_test::stress_fixture {
+protected:
+ static size_t s_nThreadCount;
+ // Simulate as the data protected by the lock.
+ static size_t locked_data;
+ static std::atomic<RcuData*> rcu_data;
+ // MicroLock
+ static size_t s_nMicroLockPassCount;
+ // MicroSpinLock
+ static size_t s_nMicroSpinLockPassCount;
+ // PicoSpinLock
+ static size_t s_nPicoSpinLockPassCount;
+ // SharedMutex
+ static size_t s_nSharedMutexPassCount;
+ // RWSpinLock
+ static size_t s_nRWSpinLockPassCount;
+ // RWTicketSpinLock
+ static size_t s_nRWTicketSpinLockPassCount;
+ // RCU
+ static size_t s_nRcuReaderPassCount;
+ static size_t s_nRcuWriterPassCount;
+ static size_t s_nRcuWriterFrequency;
+
+ static unsigned s_nSharedMutexWritePercentage;
+ static unsigned s_nRWSpinLockWritePercentage;
+ static unsigned s_nRWTicketSpinLockWritePercentage;
+
+ static void SetUpTestCase() {
+ const cds_test::config& cfg = get_config("ParallelFollySync");
+ GetConfigNonZeroExpected(ThreadCount, 4);
+ GetConfigNonZeroExpected(MicroLockPassCount, 2000000000);
+ GetConfigNonZeroExpected(MicroSpinLockPassCount, 1500000000);
+ GetConfigNonZeroExpected(PicoSpinLockPassCount, 2700000000);
+ GetConfigNonZeroExpected(SharedMutexPassCount, 5000000);
+ GetConfigNonZeroExpected(RWSpinLockPassCount, 5000000);
+ GetConfigNonZeroExpected(RWTicketSpinLockPassCount, 5000000);
+ GetConfigNonZeroExpected(RcuReaderPassCount, 10000);
+ GetConfigNonZeroExpected(RcuWriterPassCount, 500);
+ // Every 100 ms by default there will be a writer.
+ GetConfigNonZeroExpected(RcuWriterFrequency, 100);
+
+ GetConfigNonZeroExpected(SharedMutexWritePercentage, 5);
+ GetConfigNonZeroExpected(RWSpinLockWritePercentage, 5);
+ GetConfigNonZeroExpected(RWTicketSpinLockWritePercentage, 5);
+
+ rcu_data.store(new RcuData(), std::memory_order_relaxed);
+ }