New strings no longer relocatable
[folly.git] / folly / Synchronized.h
index 8a2f9b95c731943a44453afa12bc3b707976edbe..d10a97fc27350ba80daf5d28963aa39c1ff2887b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
 #include <mutex>
 #include <boost/thread.hpp>
 #include <folly/Preprocessor.h>
+#include <folly/SharedMutex.h>
 #include <folly/Traits.h>
 
 namespace folly {
@@ -224,7 +225,7 @@ releaseReadWrite(T& mutex) {
  * refer to the namespace detail below, which implements the
  * primitives for mutexes in std and boost.
  */
-template <class T, class Mutex = boost::shared_mutex>
+template <class T, class Mutex = SharedMutex>
 struct Synchronized {
   /**
    * Default constructor leaves both members call their own default
@@ -681,8 +682,8 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
  * examples.
  */
 #define SYNCHRONIZED(...)                                       \
-  _Pragma("GCC diagnostic push")                                \
-  _Pragma("GCC diagnostic ignored \"-Wshadow\"")                \
+  FOLLY_PUSH_WARNING                                            \
+  FOLLY_GCC_DISABLE_WARNING(shadow)                             \
   if (bool SYNCHRONIZED_state = false) {} else                  \
     for (auto SYNCHRONIZED_lockedPtr =                          \
            (FB_ARG_2_OR_1(__VA_ARGS__)).operator->();           \
@@ -690,7 +691,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
       for (auto& FB_ARG_1(__VA_ARGS__) =                        \
              *SYNCHRONIZED_lockedPtr.operator->();              \
            !SYNCHRONIZED_state; SYNCHRONIZED_state = true)      \
-  _Pragma("GCC diagnostic pop")
+  FOLLY_POP_WARNING
 
 #define TIMED_SYNCHRONIZED(timeout, ...)                           \
   if (bool SYNCHRONIZED_state = false) {} else                     \
@@ -722,7 +723,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
   for (decltype(SYNCHRONIZED_lockedPtr.typeHackDoNotUse())      \
          SYNCHRONIZED_state3(&SYNCHRONIZED_lockedPtr);          \
        !SYNCHRONIZED_state; SYNCHRONIZED_state = true)          \
-    for (auto name = *SYNCHRONIZED_state3.operator->();         \
+    for (auto& name = *SYNCHRONIZED_state3.operator->();        \
          !SYNCHRONIZED_state; SYNCHRONIZED_state = true)
 
 /**