proxygen
|
#include <Synchronized.h>
Public Types | |
using | LockedPtr = ::folly::LockedPtr< Subclass, LockPolicyExclusive > |
using | ConstWLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyExclusive > |
using | ConstLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyShared > |
using | TryWLockedPtr = ::folly::LockedPtr< Subclass, LockPolicyTryExclusive > |
using | ConstTryWLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyTryExclusive > |
using | TryRLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyTryShared > |
Public Member Functions | |
LockedPtr | wlock () |
TryWLockedPtr | tryWLock () |
ConstLockedPtr | rlock () const |
TryRLockedPtr | tryRLock () const |
template<class Rep , class Period > | |
LockedPtr | wlock (const std::chrono::duration< Rep, Period > &timeout) |
template<class Rep , class Period > | |
ConstLockedPtr | rlock (const std::chrono::duration< Rep, Period > &timeout) const |
template<class Function > | |
auto | withWLock (Function &&function) |
template<class Function > | |
auto | withWLockPtr (Function &&function) |
template<class Function > | |
auto | withRLock (Function &&function) const |
template<class Function > | |
auto | withRLockPtr (Function &&function) const |
SynchronizedBase specialization for shared mutex types.
This class provides wlock() and rlock() methods for acquiring the lock and accessing the data.
Definition at line 84 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::SHARED >::ConstLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyShared> |
Definition at line 89 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::SHARED >::ConstTryWLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyTryExclusive> |
Definition at line 93 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::SHARED >::ConstWLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyExclusive> |
Definition at line 88 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::SHARED >::LockedPtr = ::folly::LockedPtr<Subclass, LockPolicyExclusive> |
Definition at line 86 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::SHARED >::TryRLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyTryShared> |
Definition at line 94 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::SHARED >::TryWLockedPtr = ::folly::LockedPtr<Subclass, LockPolicyTryExclusive> |
Definition at line 91 of file Synchronized.h.
|
inline |
Acquire a read lock, and return a ConstLockedPtr that can be used to safely access the datum.
Definition at line 122 of file Synchronized.h.
|
inline |
Attempts to acquire the lock, or fails if the timeout elapses first. If acquisition is unsuccessful, the returned LockedPtr will be null.
(Use LockedPtr::operator bool() or LockedPtr::isNull() to check for validity.)
Definition at line 157 of file Synchronized.h.
|
inline |
Attempts to acquire the lock in shared mode. If acquisition is unsuccessful, the returned LockedPtr will be null.
(Use LockedPtr::operator bool() or LockedPtr::isNull() to check for validity.)
Definition at line 133 of file Synchronized.h.
|
inline |
Attempts to acquire the lock in exclusive mode. If acquisition is unsuccessful, the returned LockedPtr will be null.
(Use LockedPtr::operator bool() or LockedPtr::isNull() to check for validity.)
Definition at line 114 of file Synchronized.h.
|
inline |
Invoke a function while holding an the lock in shared mode.
A const reference to the datum will be passed into the function as its only argument.
Definition at line 202 of file Synchronized.h.
References folly::rlock().
|
inline |
Definition at line 207 of file Synchronized.h.
References folly::rlock().
|
inline |
Invoke a function while holding the lock exclusively.
A reference to the datum will be passed into the function as its only argument.
This can be used with a lambda argument for easily defining small critical sections in the code. For example:
auto value = obj.withWLock([](auto& data) { data.doStuff(); return data.getValue(); });
Definition at line 177 of file Synchronized.h.
References folly::wlock().
|
inline |
Invoke a function while holding the lock exclusively.
This is similar to withWLock(), but the function will be passed a LockedPtr rather than a reference to the data itself.
This allows scopedUnlock() to be called on the LockedPtr argument if desired.
Definition at line 191 of file Synchronized.h.
References folly::wlock().
|
inline |
Acquire an exclusive lock, and return a LockedPtr that can be used to safely access the datum.
LockedPtr offers operator -> and * to provide access to the datum. The lock will be released when the LockedPtr is destroyed.
Definition at line 103 of file Synchronized.h.
|
inline |
Attempts to acquire the lock, or fails if the timeout elapses first. If acquisition is unsuccessful, the returned LockedPtr will be null.
(Use LockedPtr::operator bool() or LockedPtr::isNull() to check for validity.)
Definition at line 145 of file Synchronized.h.