ReadWriteLock Class Reference

A Read/Write lock -- a synchronization primitive that allows multiple threads to coordinate access to a mutable resource. More...

#include <ReadWriteLock.h++>

List of all members.

Public Member Functions

 ReadWriteLock () throw ()
 Construct a new ReadWriteLock.
 ~ReadWriteLock () throw ()
 Destructor.
void lockRead () throw ()
 Acquire a read lock, blocking until the lock is acquired.
bool tryLockRead (timespan_ms_t timeout=0) throw ()
 Try to acquire a read lock, returning if the lock could not be acquired within the given amount of time.
void lockWrite () throw ()
 Acquire a write lock, blocking until the lock is acquired.
bool tryLockWrite (timespan_ms_t timeout=0) throw ()
 Try to acquire a write lock, returning if the lock could not be acquired within the given amount of time.
void unlock () throw ()
 Release the lock.

Static Public Member Functions

static bool supportsTimedLocks () throw ()
 Determine if the host system supports timed read/write locks.

Detailed Description

A Read/Write lock -- a synchronization primitive that allows multiple threads to coordinate access to a mutable resource.

Any number of threads can simultaneously hold the read lock as long as no thread holds the write lock. Conversely, a thread can acquire the write lock as long as no threads are holding the read lock.

See also ScopedReadLock and ScopedWriteLock.

Author:
Mark Lindner

Constructor & Destructor Documentation

ReadWriteLock (  )  throw ()

Construct a new ReadWriteLock.

~ReadWriteLock (  )  throw ()

Destructor.


Member Function Documentation

void lockRead (  )  throw ()

Acquire a read lock, blocking until the lock is acquired.

void lockWrite (  )  throw ()

Acquire a write lock, blocking until the lock is acquired.

bool supportsTimedLocks (  )  throw () [static]

Determine if the host system supports timed read/write locks.

bool tryLockRead ( timespan_ms_t  timeout = 0  )  throw ()

Try to acquire a read lock, returning if the lock could not be acquired within the given amount of time.

On platforms that do not support timed read/write locks, the method returns immediately if the lock could not be acquired.

Parameters:
timeout The timeout, in milliseconds.
Returns:
true if the lock was acquired, false otherwise.
bool tryLockWrite ( timespan_ms_t  timeout = 0  )  throw ()

Try to acquire a write lock, returning if the lock could not be acquired within the given amount of time.

On platforms that do not support timed read/write locks, the method returns immediately if the lock could not be acquired.

Parameters:
timeout The timeout, in milliseconds.
Returns:
true if the lock was acquired, false otherwise.
void unlock (  )  throw ()

Release the lock.


The documentation for this class was generated from the following files:
Generated on Sat Nov 26 16:49:09 2011 for libcommonc++ by  doxygen 1.6.3