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

Phx::LockHolder Class Reference

A safe locking class for a simple Lock. More...

#include <PhxLocks.h>

List of all members.

Public Member Functions

 LockHolder (const Lock *lock)
 Constructs a new lock holder, which takes and holds the mutex.
 LockHolder (LockHolder *lockHolder)
 Creates a new lock holder that takes over ownership of a lock from another lock holder.
 ~LockHolder ()
 Destructor that releases the lock held by this LockHolder.
void unlock (void)
 Explicitly unlocks the mutex held by this LockHolder.


Detailed Description

A safe locking class for a simple Lock.

This is used as a safe locking mechanism in the presence of exceptions. Pass it the lock to be locked. The constructor will attempt to acquire the lock and will return when it has done so. When this object is destructed the lock will be released.


Constructor & Destructor Documentation

Phx::LockHolder::LockHolder const Lock lock  ) 
 

Constructs a new lock holder, which takes and holds the mutex.

Parameters:
lock The lock that will be acquired. If this is NULL then this becomes an inert lock holder that does nothing.

Phx::LockHolder::LockHolder LockHolder lockHolder  ) 
 

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

Parameters:
lockHolder A pointer to the lock holder from which to acquire the lock. When this is complete, 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::LockHolder::~LockHolder  ) 
 

Destructor that releases the lock held by this LockHolder.

If the ownership of the lock was transferred to another holder, this does nothing.


Member Function Documentation

void Phx::LockHolder::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