Quick Links:

bal | bbl | bdl | bsl

Public Member Functions

bslmt::RWMutex Class Reference

#include <bslmt_rwmutex.h>

List of all members.

Public Member Functions

 RWMutex ()
 ~RWMutex ()
void lockRead ()
void lockWrite ()
int tryLockRead ()
int tryLockWrite ()
void unlock ()

Detailed Description

This class is a platform-independent interface to a reader-writer lock ("RW mutex"). Multiple readers can safely hold the lock simultaneously, whereas only one writer is allowed to hold the lock at a time. This class uses the most efficient RW mutex implementation available for the current platform. Note that the implementation may allow readers to starve writers.

See Component bslmt_rwmutex


Constructor & Destructor Documentation

bslmt::RWMutex::RWMutex (  ) 

Create an RW mutex initialized to an unlocked state.

bslmt::RWMutex::~RWMutex (  ) 

Destroy this RW mutex. The behavior is undefined if the mutex is in a locked state.


Member Function Documentation

void bslmt::RWMutex::lockRead (  ) 

Lock this reader-writer mutex for reading. If there are no active or pending write locks, lock this mutex for reading and return immediately. Otherwise, block until the read lock on this mutex is acquired. Use unlock to release the lock on this mutex. The behavior is undefined if this method is called from a thread that already has a lock on this mutex.

void bslmt::RWMutex::lockWrite (  ) 

Lock this reader-writer mutex for writing. If there are no active or pending locks on this mutex, lock this mutex for writing and return immediately. Otherwise, block until the write lock on this mutex is acquired. Use unlock to release the lock on this mutex. The behavior is undefined if this method is called from a thread that already has a lock on this mutex.

int bslmt::RWMutex::tryLockRead (  ) 

Attempt to lock this reader-writer mutex for reading. Immediately return 0 on success, and a non-zero value if there are active or pending writers. If successful, unlock must be used to release the lock on this mutex. The behavior is undefined if this method is called from a thread that already has a lock on this mutex.

int bslmt::RWMutex::tryLockWrite (  ) 

Attempt to lock this reader-writer mutex for writing. Immediately return 0 on success, and a non-zero value if there are active or pending locks on this mutex. If successful, unlock must be used to release the lock on this mutex. The behavior is undefined if this method is called from a thread that already has a lock on this mutex.

void bslmt::RWMutex::unlock (  ) 

Release the lock that the calling thread holds on this reader-writer mutex. The behavior is undefined unless the calling thread currently has a lock on this mutex.


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