A readers‐writer lock which allows multiple readers to hold the lock simultaneously or only one writer.
Synopsis
Declared in <folly/fibers/TimedMutex.h>
template<
bool ReaderPriority,
typename BatonType>
class TimedRWMutexImpl;
Description
NOTE: When ReaderPriority is set to true then the lock is a reader‐preferred RWLock i.e. readers are given priority when there are both readers and writers waiting to get the lock.
When ReaderPriority is set to false then the lock is a writer‐preferred RWLock i.e. writers are given priority when there are both readers and writers waiting to get the lock. Note that when the lock is in writer‐preferred mode, the readers are not re‐entrant (e.g. if a caller owns a read lock, it can't attempt to acquire the read lock again as it can deadlock.)
Member Functions
Name |
Description |
|
Constructors |
|
Destroy the mutex. |
Assignment operators |
|
Obtain an exclusive lock. The thread / fiber is blocked until the lock is available. |
|
Lock for shared access. The thread / fiber is blocked until the lock can be acquired. |
|
Like lock but doesn't block the thread / fiber if the lock cant be obtained. |
|
Like lock except the thread / fiber is blocked until a timeout elapses. |
|
Like lock_shared but doesn't block the thread / fiber if the lock can't be acquired. |
|
Like lock_shared except the thread / fiber is blocked until a timeout elapses. |
|
Like lock_shared except the thread / fiber is blocked until a deadline. |
|
Like lock except the thread / fiber is blocked until a deadline. |
|
Release the exclusive lock. The thread / fiber will wake up all readers if there are any. If there are waiting writers then only one of them will be woken up. |
|
Downgrade the lock. The thread / fiber will wake up all readers if there are any. |
|
Release the shared lock. The thread / fiber will wake up a writer if there is one and if this is the last concurrently‐held read lock to be released. |
Created with MrDocs