proxygen
|
#include <Synchronized.h>
Public Types | |
using | LockedPtr = ::folly::LockedPtr< Subclass, LockPolicyExclusive > |
using | ConstLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyExclusive > |
using | TryLockedPtr = ::folly::LockedPtr< Subclass, LockPolicyTryExclusive > |
using | ConstTryLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyTryExclusive > |
Public Member Functions | |
LockedPtr | lock () |
ConstLockedPtr | lock () const |
TryLockedPtr | tryLock () |
ConstTryLockedPtr | tryLock () const |
template<class Rep , class Period > | |
LockedPtr | lock (const std::chrono::duration< Rep, Period > &timeout) |
template<class Rep , class Period > | |
ConstLockedPtr | lock (const std::chrono::duration< Rep, Period > &timeout) const |
template<class Function > | |
auto | withLock (Function &&function) |
template<class Function > | |
auto | withLock (Function &&function) const |
template<class Function > | |
auto | withLockPtr (Function &&function) |
template<class Function > | |
auto | withLockPtr (Function &&function) const |
SynchronizedBase specialization for non-shared mutex types.
This class provides lock() methods for acquiring the lock and accessing the data.
Definition at line 314 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UNIQUE >::ConstLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyExclusive> |
Definition at line 318 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UNIQUE >::ConstTryLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyTryExclusive> |
Definition at line 322 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UNIQUE >::LockedPtr = ::folly::LockedPtr<Subclass, LockPolicyExclusive> |
Definition at line 316 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UNIQUE >::TryLockedPtr = ::folly::LockedPtr<Subclass, LockPolicyTryExclusive> |
Definition at line 320 of file Synchronized.h.
|
inline |
Acquire a lock, and return a LockedPtr that can be used to safely access the datum.
Definition at line 328 of file Synchronized.h.
|
inline |
Acquire a lock, and return a ConstLockedPtr that can be used to safely access the datum.
Definition at line 336 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.
Definition at line 359 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.
Definition at line 368 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 347 of file Synchronized.h.
|
inline |
Definition at line 350 of file Synchronized.h.
|
inline |
Invoke a function while holding the lock.
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.withLock([](auto& data) { data.doStuff(); return data.getValue(); });
Definition at line 387 of file Synchronized.h.
References folly::lock().
|
inline |
Definition at line 391 of file Synchronized.h.
References folly::lock().
|
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() and getUniqueLock() to be called on the LockedPtr argument.
Definition at line 405 of file Synchronized.h.
References folly::lock().
|
inline |
Definition at line 409 of file Synchronized.h.
References folly::lock().