Move folly/RWSpinLock.h to folly/synchronization/
[folly.git] / folly / test / SharedMutexTest.cpp
index d18e3b6e263592fa87ce91801b898c74ba71877d..98f7a1592ee54e8e2d370fee9248b8e4687b1109 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #include <folly/SharedMutex.h>
 
 #include <stdlib.h>
 
 #include <folly/Benchmark.h>
 #include <folly/MPMCQueue.h>
-#include <folly/RWSpinLock.h>
 #include <folly/portability/GFlags.h>
 #include <folly/portability/GTest.h>
+#include <folly/synchronization/RWSpinLock.h>
 #include <folly/test/DeterministicSchedule.h>
 
 using namespace folly;
 using namespace folly::test;
 using namespace std;
-using namespace chrono;
+using namespace std::chrono;
 
 typedef DeterministicSchedule DSched;
 typedef SharedMutexImpl<true, void, DeterministicAtomic, true>
@@ -98,7 +97,7 @@ void runBasicHoldersTest() {
     EXPECT_FALSE(lock.try_lock_shared(token));
 
     // move ownership to another write holder via assign operator
-    typename Lock::WriteHolder holder3;
+    typename Lock::WriteHolder holder3(nullptr);
     holder3 = std::move(holder2);
     EXPECT_FALSE(lock.try_lock());
     EXPECT_FALSE(lock.try_lock_shared(token));
@@ -1052,14 +1051,14 @@ TEST(SharedMutex, deterministic_lost_wakeup_write_prio) {
 }
 
 TEST(SharedMutex, mixed_mostly_write_read_prio) {
-  for (int pass = 0; pass < 5; ++pass) {
+  for (int pass = 0; pass < (folly::kIsSanitizeAddress ? 1 : 5); ++pass) {
     runMixed<atomic, SharedMutexReadPriority, TokenLocker>(
         50000, 300, 0.9, false);
   }
 }
 
 TEST(SharedMutex, mixed_mostly_write_write_prio) {
-  for (int pass = 0; pass < 5; ++pass) {
+  for (int pass = 0; pass < (folly::kIsSanitizeAddress ? 1 : 5); ++pass) {
     runMixed<atomic, SharedMutexWritePriority, TokenLocker>(
         50000, 300, 0.9, false);
   }
@@ -1229,7 +1228,7 @@ TEST(SharedMutex, remote_write_prio) {
 }
 
 TEST(SharedMutex, remote_read_prio) {
-  for (int pass = 0; pass < 100; ++pass) {
+  for (int pass = 0; pass < (folly::kIsSanitizeAddress ? 1 : 100); ++pass) {
     runRemoteUnlock<SharedMutexReadPriority, atomic>(100000, 0.1, 0.1, 5, 5);
   }
 }