#include <mutex>
#include <boost/thread.hpp>
#include <folly/Preprocessor.h>
+#include <folly/SharedMutex.h>
#include <folly/Traits.h>
namespace folly {
* 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
explicit Synchronized(T&& rhs) noexcept(nxMoveCtor)
: datum_(std::move(rhs)) {}
+ /**
+ * Lets you construct non-movable types in-place. Use the constexpr
+ * instance `construct_in_place` as the first argument.
+ */
+ template <typename... Args>
+ explicit Synchronized(construct_in_place_t, Args&&... args)
+ : datum_(std::forward<Args>(args)...) {}
+
/**
* The canonical assignment operator only assigns the data, NOT the
* mutex. It locks the two objects in ascending order of their
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)
/**