Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Phx::ReadLockHolder Class Reference

A safe locking class for the reader side of a reader/writer lock. More...

#include <PhxLocks.h>

List of all members.

Public Member Functions

 ReadLockHolder (const ReadWriteLock *lock)
 Constructs a new reader lock holder, which takes and holds the reader privilege to a reader/writer lock.
 ReadLockHolder (ReadLockHolder *lockHolder)
 Creates a new lock holder that takes over ownership of a read lock from another read-lock holder.
 ~ReadLockHolder ()
 Destructor that releases the reader lock.
void unlock (void)
 Explicitly unlocks the mutex held by this LockHolder.


Detailed Description

A safe locking class for the reader side of a reader/writer lock.

This is used as a safe locking mechanism in the presence of exceptions. Pass it the read/write lock to be locked. The constructor will lock the given mutex for reading and only return once it is obtained (or throw an exception in the case of error). When this object is destructed, the lock is released.


Constructor & Destructor Documentation

Phx::ReadLockHolder::ReadLockHolder const ReadWriteLock lock  ) 
 

Constructs a new reader lock holder, which takes and holds the reader privilege to a reader/writer lock.

Parameters:
lock The reader/writer lock that will be locked for reading. If lock is NULL then this becomes an inert holder that does nothing.

Phx::ReadLockHolder::ReadLockHolder ReadLockHolder lockHolder  ) 
 

Creates a new lock holder that takes over ownership of a read lock from another read-lock holder.

Parameters:
lockHolder The lock holder from which to acquire the lock. When this is complete, the lockHolder will be inert and will not change the lock when it destructs.
Warning:
You should avoid using this as a "regular old copy" constructor. That is not what it does. The purpose of this constructor is to make it possible to acquire a lock ahead of some other operation which also needs the lock and then "hand off" the lock at the proper time without ever releasing and reacquiring it.

Phx::ReadLockHolder::~ReadLockHolder  ) 
 

Destructor that releases the reader lock.

If the lock was transferred to another owner then this does nothing.


Member Function Documentation

void Phx::ReadLockHolder::unlock void   ) 
 

Explicitly unlocks the mutex held by this LockHolder.

Once this is called, the lock is released and this holder will do nothing on destruction.


The documentation for this class was generated from the following file:
Generated on Mon Jul 10 19:45:30 2006 for Phoenix OSFS by  doxygen 1.4.2