#include <bslmt_readerwriterlock.h>
This class provides a multi-reader/single-writer lock mechanism.
See bslmt_readerwriterlock
◆ ReaderWriterLock()
bslmt::ReaderWriterLock::ReaderWriterLock |
( |
| ) |
|
|
inline |
◆ ~ReaderWriterLock()
bslmt::ReaderWriterLock::~ReaderWriterLock |
( |
| ) |
|
|
inline |
◆ isLocked()
bool bslmt::ReaderWriterLock::isLocked |
( |
| ) |
const |
|
inline |
Return true
if this reader-write lock is currently read locked or write locked, and false
otherwise.
◆ isLockedRead()
bool bslmt::ReaderWriterLock::isLockedRead |
( |
| ) |
const |
|
inline |
Return true
if this reader-write lock is currently read locked, and false
otherwise.
◆ isLockedWrite()
bool bslmt::ReaderWriterLock::isLockedWrite |
( |
| ) |
const |
|
inline |
Return true
if this reader-write lock is currently write locked, and false
otherwise.
◆ lockRead()
void bslmt::ReaderWriterLock::lockRead |
( |
| ) |
|
Lock this reader/writer lock for read. If there are no pending or active write locks, the call will return immediately, otherwise it block until all write locks have been released. Use unlock
to release the lock.
◆ lockReadReserveWrite()
void bslmt::ReaderWriterLock::lockReadReserveWrite |
( |
| ) |
|
Lock this reader/writer lock for read and reserve a write lock so that a call to upgradeToWriteLock
is guaranteed to upgrade atomically. If there are no pending or active write locks, the call will return immediately, otherwise it will block until it all active and pending writes have completed. The lock may then be atomically converted to a write lock by calling upgradeToWriteLock
. Use unlock
to release the lock.
◆ lockWrite()
void bslmt::ReaderWriterLock::lockWrite |
( |
| ) |
|
Lock the reader/writer lock for write. The call will block until all active read locks or active/pending write locks are released. When the reader/writer lock is locked for write, all read/write lock attempts will either fail or block until the lock is released. Use unlock
to release the lock.
◆ tryLockRead()
int bslmt::ReaderWriterLock::tryLockRead |
( |
| ) |
|
Attempt to lock this reader/writer lock for read. Return 0 on success, and a non-zero value if the lock is currently locked for write or if there are writers waiting for this lock. If successful, unlock
must be used to release this lock.
◆ tryLockWrite()
int bslmt::ReaderWriterLock::tryLockWrite |
( |
| ) |
|
Attempt to lock this reader/writer lock for write. Return 0 on success, and a non-zero value if the lock already locked for read or write. If successful, unlock
must be called to release the lock.
◆ tryUpgradeToWriteLock()
int bslmt::ReaderWriterLock::tryUpgradeToWriteLock |
( |
| ) |
|
Attempt to atomically convert a read lock (acquired by a successful call to lockRead
, lockReadReserveWrite
, or tryLockRead
) to a write lock. Return 0 on success, and a non-zero value otherwise. If a write lock request is already pending, a non-zero value is immediately returned. If there are other active read locks, the call will block until all current read locks are released. Note that locks that were acquired through lockReadReserveWrite
are guaranteed to succeed.
◆ unlock()
void bslmt::ReaderWriterLock::unlock |
( |
| ) |
|
Release a read lock that was previously acquired from a successful call to lockRead
, lockReadReserveWrite
, or tryLockRead
, or a call to write lock which was previously acquired by a successful call to lockWrite
, tryLockWrite
, or upgradeToWriteLock
. Note that the behavior is undefined unless the calling thread currently owns this read/write lock.
◆ unlockRead()
void bslmt::ReaderWriterLock::unlockRead |
( |
| ) |
|
|
inline |
- Deprecated:
- Use unlock instead. Note that calls to this function are simply forwarded to
unlock
.
◆ unlockReadUnreserveWrite()
void bslmt::ReaderWriterLock::unlockReadUnreserveWrite |
( |
| ) |
|
|
inline |
- Deprecated:
- Use unlock instead. Note that calls to this function are simply forwarded to
unlock
.
◆ unlockWrite()
void bslmt::ReaderWriterLock::unlockWrite |
( |
| ) |
|
|
inline |
- Deprecated:
- Use unlock instead. Note that calls to this function are simply forwarded to
unlock
.
◆ upgradeToWriteLock()
int bslmt::ReaderWriterLock::upgradeToWriteLock |
( |
| ) |
|
Convert a read lock (acquired by a successful call to lockRead
, lockReadReserveWrite
, or tryLockRead
) to a write lock. Return 0 if the upgrade operation was atomic, and a non-zero value otherwise. If there are other active read locks, the call will block until all current read locks are released. Note that locks that were acquired through lockReadReserveWrite
are guaranteed to upgrade atomically. Use unlock
to release this lock.
The documentation for this class was generated from the following file: