Quick Links:

bal | bbl | bdl | bsl

Public Member Functions

bslmt::ReaderWriterLock Class Reference

#include <bslmt_readerwriterlock.h>

List of all members.

Public Member Functions

 ReaderWriterLock ()
 ~ReaderWriterLock ()
void lockRead ()
void lockReadReserveWrite ()
void lockWrite ()
int tryLockRead ()
int tryLockWrite ()
int upgradeToWriteLock ()
int tryUpgradeToWriteLock ()
void unlockRead ()
void unlockReadUnreserveWrite ()
void unlockWrite ()
void unlock ()
bool isLocked () const
bool isLockedRead () const
bool isLockedWrite () const

Detailed Description

This class provides a multi-reader/single-writer lock mechanism.

See Component bslmt_readerwriterlock


Constructor & Destructor Documentation

bslmt::ReaderWriterLock::ReaderWriterLock (  ) 

Construct a reader/writer lock initialized to an unlocked state.

bslmt::ReaderWriterLock::~ReaderWriterLock (  ) 

Destroy this reader/writer lock.


Member Function Documentation

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.

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.

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.

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.

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.

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.

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.

void bslmt::ReaderWriterLock::unlockRead (  ) 

DEPRECATED Use unlock instead. Note that calls to this function are simply forwarded to unlock.

void bslmt::ReaderWriterLock::unlockReadUnreserveWrite (  ) 

DEPRECATED Use unlock instead. Note that calls to this function are simply forwarded to unlock.

void bslmt::ReaderWriterLock::unlockWrite (  ) 

DEPRECATED Use unlock instead. Note that calls to this function are simply forwarded to 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.

bool bslmt::ReaderWriterLock::isLocked (  )  const

Return true if this reader-write lock is currently read locked or write locked, and false otherwise.

bool bslmt::ReaderWriterLock::isLockedRead (  )  const

Return true if this reader-write lock is currently read locked, and false otherwise.

bool bslmt::ReaderWriterLock::isLockedWrite (  )  const

Return true if this reader-write lock is currently write locked, and false otherwise.


The documentation for this class was generated from the following file: