proxygen
|
#include <Synchronized.h>
Public Types | |
using | UpgradeLockedPtr = ::folly::LockedPtr< Subclass, LockPolicyUpgrade > |
using | ConstUpgradeLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyUpgrade > |
using | TryUpgradeLockedPtr = ::folly::LockedPtr< Subclass, LockPolicyTryUpgrade > |
using | ConstTryUpgradeLockedPtr = ::folly::LockedPtr< const Subclass, LockPolicyTryUpgrade > |
![]() | |
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 | |
UpgradeLockedPtr | ulock () |
TryUpgradeLockedPtr | tryULock () |
template<class Rep , class Period > | |
UpgradeLockedPtr | ulock (const std::chrono::duration< Rep, Period > &timeout) |
template<class Function > | |
auto | withULock (Function &&function) |
template<class Function > | |
auto | withULockPtr (Function &&function) |
![]() | |
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 upgrade mutex types.
This class provides all the functionality provided by the SynchronizedBase specialization for shared mutexes and a ulock() method that returns an upgradable lock RAII proxy
Definition at line 220 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UPGRADE >::ConstTryUpgradeLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyTryUpgrade> |
Definition at line 230 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UPGRADE >::ConstUpgradeLockedPtr = ::folly::LockedPtr<const Subclass, LockPolicyUpgrade> |
Definition at line 225 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UPGRADE >::TryUpgradeLockedPtr = ::folly::LockedPtr<Subclass, LockPolicyTryUpgrade> |
Definition at line 228 of file Synchronized.h.
using folly::SynchronizedBase< Subclass, detail::MutexLevel::UPGRADE >::UpgradeLockedPtr = ::folly::LockedPtr<Subclass, LockPolicyUpgrade> |
Definition at line 223 of file Synchronized.h.
|
inline |
Attempts to acquire the lock in upgrade 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 249 of file Synchronized.h.
|
inline |
Acquire an upgrade lock and return a LockedPtr that can be used to safely access the datum
And the const version
Definition at line 238 of file Synchronized.h.
|
inline |
Acquire an upgrade lock and return a LockedPtr that can be used to safely access the datum
And the const version
Definition at line 260 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.withULock([](auto& data) { data.doStuff(); return data.getValue(); });
This is probably not the function you want. If the intent is to read the data object and determine whether you should upgrade to a write lock then the withULockPtr() method should be called instead, since it gives access to the LockedPtr proxy (which can be upgraded via the moveFromUpgradeToWrite() method)
Definition at line 285 of file Synchronized.h.
References folly::ulock().
|
inline |
Invoke a function while holding the lock exclusively.
This is similar to withULock(), 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.
This also allows you to upgrade the LockedPtr proxy to a write state so that changes can be made to the underlying data
Definition at line 302 of file Synchronized.h.
References folly::ulock().