Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members  

RWLock Class Reference

#include <RWLock.h>

Inheritance diagram for RWLock:

BiasedRWLock FairRWLock List of all members.

Public Methods

 RWLock () throw (Synchronization_Exception)
virtual ~RWLock () throw ()
LockablegetReadLock ()
LockablegetWriteLock ()

Protected Methods

virtual bool allowReader ()
virtual bool allowWriter ()
virtual void beforeRead () throw (Synchronization_Exception)
virtual void beforeWrite () throw (Synchronization_Exception)
virtual bool beforeRead (unsigned long) throw (Synchronization_Exception)
virtual bool beforeWrite (unsigned long) throw (Synchronization_Exception)
virtual void postRead () throw (Synchronization_Exception)
virtual void postWrite () throw (Synchronization_Exception)

Protected Attributes

FastMutex _mtxLock
 Serialize access to this object.

Condition _condRead
 Notified on read ready.

Condition _condWrite
 Notified on write read.

Lockable_readLock
 RLock.

Lockable_writeLock
 WLock.

volatile int _fairnessCounter
 track fairness.

volatile int _activeReaders
 track the current readers.

volatile int _activeWriters
 track the current writers.

volatile int _waitingReaders
 track the waiting readers.

volatile int _waitingWriters
 track the waiting writers.


Friends

class RLock
 friend.

class WLock
 friend.


Detailed Description

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-05-28T20:19:52-0400>
Version:
2.1.3
Read/Write lock provide a set of coordinated Lockable object that allow many Readers while there is no update in progress, but only 1 Writer & 0 Readers during an update

Because the general case where an RWLock would be used is one where you have more readers than writers, this lock will have a bias toward readers


Constructor & Destructor Documentation

RWLock   throw (Synchronization_Exception)
 

Create a new RWLock

Exceptions:
Initialization_Exception  - thrown if resources could not be allocated

virtual ~RWLock   throw () [virtual]
 

Destroy this RWLock


Member Function Documentation

virtual bool allowReader   [protected, virtual]
 

Checked before a lock is acquired. Changing this function in a subclass can create RWLocks with different biases.

Returns:
bool - true, allow lock to be acquired, false block

Reimplemented in BiasedRWLock, and FairRWLock.

virtual bool allowWriter   [protected, virtual]
 

Checked before a lock is acquired. Changing this function in a subclass can create RWLocks with different biases.

Returns:
bool - true, allow lock to be acquired, false block

virtual bool beforeRead unsigned    long throw (Synchronization_Exception) [protected, virtual]
 

Called just before a read lock tryAcquire()

Parameters:
long  - timeout the read will be called with

virtual void beforeRead   throw (Synchronization_Exception) [protected, virtual]
 

Called just prior to a read lock acquire()

virtual bool beforeWrite unsigned    long throw (Synchronization_Exception) [protected, virtual]
 

Called just before a write lock tryAcquire()

Parameters:
long  - timeout the write will be called with

virtual void beforeWrite   throw (Synchronization_Exception) [protected, virtual]
 

Called just prior to a write lock acquire()

Lockable* getReadLock   [inline]
 

Get a reference to the read lock

Returns:
Lockable read lock

Lockable* getWriteLock   [inline]
 

Get a reference to the write lock

Returns:
Lockable write lock

virtual void postRead   throw (Synchronization_Exception) [protected, virtual]
 

Called after a read lock is released

virtual void postWrite   throw (Synchronization_Exception) [protected, virtual]
 

Called after a write lock is released


The documentation for this class was generated from the following file:
Generated on Mon Jun 10 22:44:46 2002 for ZThread by doxygen1.2.15