A thread lock for shared data where there may be many readers and one writer.
More...
|
| | SharedMutex () |
| |
| | SharedMutex (const SharedMutex &) |
| | Can't copy, silently inits to default. More...
|
| |
| | ~SharedMutex () |
| |
| SharedMutex & | operator= (const SharedMutex &) |
| | Can't copy, silently does nothing. More...
|
| |
| void | lock () |
| | Acquire the unique writer lock. Thread suspends until lock is available and all readers release the shared lock. More...
|
| |
| void | unlock () |
| | Release the unique writer lock. More...
|
| |
| bool | tryLock () |
| | Attempt to acquire the unique writer lock, returns immediately. Returns true if the lock was acquired, false otherwise. More...
|
| |
| bool | tryLock (MonoClock::Duration time) |
| | Attempt to acquire the unique writer lock for an amount of time. Returns true if the lock was acquired, false if timed out. More...
|
| |
| bool | tryLock (MonoClock::TimePoint time) |
| | Attempt to acquire the unique writer lock until a certain time. Returns true if the lock was acquired, false if timed out. More...
|
| |
| void | lockShared () |
| | Acquire the shared reader lock. Thread suspends until writer lock has been released. More...
|
| |
| void | unlockShared () |
| | Release the shared reader lock. More...
|
| |
| bool | tryLockShared () |
| | Attempt to acquire the shared reader lock, returns immediately. Returns true if the lock was acquired, false otherwise. More...
|
| |
| bool | tryLockShared (MonoClock::Duration time) |
| | Attempt to acquire the shared reader lock for an amount of time. Returns true if the lock was acquired, false if timed out. More...
|
| |
| bool | tryLockShared (MonoClock::TimePoint time) |
| | Attempt to acquire the shared reader lock until a certain time. Returns true if the lock was acquired, false if timed out. More...
|
| |
| void | unlockAndLockShared () |
| | Atomically unlock unique writer lock and acquire shared reader lock without blocking. More...
|
| |
A thread lock for shared data where there may be many readers and one writer.
A thread acquiring a writer lock will suspend execution while there are readers.
The lock is recursive: one thread can acquire the lock multiple times, which must be followed by the same number of unlocks.
This class uses atomics, so locking without contention is faster than a platform Mutex.