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

Phx::WriteLockHolder Class Reference

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

#include <PhxLocks.h>

List of all members.

Public Member Functions

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


Detailed Description

A safe locking class for the writer 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 writing 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::WriteLockHolder::WriteLockHolder const ReadWriteLock lock  ) 
 

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

Parameters:
lock The reader/writer lock that will be locked for writing. If lock is NULL, this becomes an inert object that does nothing.

Phx::WriteLockHolder::WriteLockHolder WriteLockHolder lockHolder  ) 
 

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

Parameters:
lockHolder The lock holder from whom to acquire the lock. When this is complete, the other lock holder 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::WriteLockHolder::~WriteLockHolder  ) 
 

Destructor that releases the writer lock.

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


Member Function Documentation

void Phx::WriteLockHolder::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 Wed Dec 21 22:05:39 2005 for Phoenix OSFS by  doxygen 1.4.2