|
| LockedPtrBase () |
|
| LockedPtrBase (SynchronizedType *parent) |
|
template<class Rep , class Period > |
| LockedPtrBase (SynchronizedType *parent, const std::chrono::duration< Rep, Period > &timeout) |
|
| LockedPtrBase (LockedPtrBase &&rhs) noexcept |
|
LockedPtrBase & | operator= (LockedPtrBase &&rhs) noexcept |
|
template<typename LockPolicyType > |
| LockedPtrBase (LockedPtrBase< SynchronizedType, Mutex, LockPolicyType > &&rhs) noexcept |
|
template<typename LockPolicyType > |
LockedPtrBase & | operator= (LockedPtrBase< SynchronizedType, Mutex, LockPolicyType > &&rhs) noexcept |
|
template<typename LockPolicyLhs , typename LockPolicyRhs > |
void | assignImpl (LockedPtrBase< SynchronizedType, Mutex, LockPolicyLhs > &lhs, LockedPtrBase< SynchronizedType, Mutex, LockPolicyRhs > &rhs) noexcept |
|
UnlockerData | releaseLock () |
|
void | reacquireLock (UnlockerData &&data) |
|
template<class SynchronizedType, class Mutex, class LockPolicy>
class folly::LockedPtrBase< SynchronizedType, Mutex, LockPolicy >
A helper base class for implementing LockedPtr.
The main reason for having this as a separate class is so we can specialize it for std::mutex, so we can expose a std::unique_lock to the caller when std::mutex is being used. This allows callers to use a std::condition_variable with the mutex from a Synchronized<T, std::mutex>.
We don't use std::unique_lock with other Mutex types since it makes the LockedPtr class slightly larger, and it makes the logic to support ScopedUnlocker slightly more complicated. std::mutex is the only one that really seems to benefit from the unique_lock. std::condition_variable itself only supports std::unique_lock<std::mutex>, so there doesn't seem to be any real benefit to exposing the unique_lock with other mutex types.
Note that the SynchronizedType template parameter may or may not be const qualified.
Definition at line 47 of file Synchronized.h.
template<class SynchronizedType, class Mutex, class LockPolicy>
template<typename LockPolicyType >
Templated move construct and assignment operators
These allow converting LockedPtr types that have the same unlocking policy to each other. This allows us to write code like
auto wlock = sync.wlock(); wlock.unlock();
auto ulock = sync.ulock(); wlock = ulock.moveFromUpgradeToWrite();
Definition at line 1058 of file Synchronized.h.
SynchronizedType * parent_
FOLLY_PUSH_WARNING RHS rhs
T exchange(T &obj, U &&new_value)
template<class SynchronizedType, class Mutex, class LockPolicy>
Get a pointer to the Synchronized object from the UnlockerData.
In the generic case UnlockerData is just the Synchronized pointer, so we return it as is. (This function is more interesting in the std::mutex specialization below.)
Definition at line 1091 of file Synchronized.h.
constexpr auto data(C &c) -> decltype(c.data())