Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

vpr::Guard Class Template Reference

Guard wrapper. More...

#include <Guard.h>

Collaboration diagram for vpr::Guard:

Collaboration graph
[legend]
List of all members.

Public Methods

 Guard (LOCK_TYPE &lock, int block=1)
 Acquires the lock implicitly. More...

 ~Guard ()
 Releases the lock. More...

const bool & locked ()
vpr::ReturnStatus acquire ()
 Acquires the lock. More...

vpr::ReturnStatus tryAcquire ()
 Tries to acquire lock. More...

vpr::ReturnStatus release ()
 Explicity releases the lock. More...


Detailed Description

template<class LOCK_TYPE>
class vpr::Guard< LOCK_TYPE >

Guard wrapper.

Date:
1-31-97

Definition at line 58 of file Guard.h.


Constructor & Destructor Documentation

template<class LOCK_TYPE>
vpr::Guard< LOCK_TYPE >::Guard LOCK_TYPE &    lock,
int    block = 1
[inline]
 

Acquires the lock implicitly.

If block = 1 then use a blocking acquire.

Definition at line 65 of file Guard.h.

References acquire, vpr::ReturnStatus::success, and tryAcquire.

00065                                          : mTheLock(&lock)
00066    {
00067       mLockStatus = block ? acquire().success() : tryAcquire().success();
00068    }

template<class LOCK_TYPE>
vpr::Guard< LOCK_TYPE >::~Guard   [inline]
 

Releases the lock.

Definition at line 71 of file Guard.h.

00072    {
00073       if ( mLockStatus )
00074       {
00075          mTheLock->release();
00076       }
00077    }


Member Function Documentation

template<class LOCK_TYPE>
const bool& vpr::Guard< LOCK_TYPE >::locked   [inline]
 

Returns:
true is returned if this guard is locked. false is returned if this guard is not locked.

Definition at line 83 of file Guard.h.

00084    {
00085       return mLockStatus;
00086    }

template<class LOCK_TYPE>
vpr::ReturnStatus vpr::Guard< LOCK_TYPE >::acquire void    [inline]
 

Acquires the lock.

Definition at line 89 of file Guard.h.

Referenced by Guard.

00090    {
00091       return mTheLock->acquire();
00092    }

template<class LOCK_TYPE>
vpr::ReturnStatus vpr::Guard< LOCK_TYPE >::tryAcquire void    [inline]
 

Tries to acquire lock.

Definition at line 95 of file Guard.h.

Referenced by Guard.

00096    {
00097       return mTheLock->tryAcquire();
00098    }

template<class LOCK_TYPE>
vpr::ReturnStatus vpr::Guard< LOCK_TYPE >::release void    [inline]
 

Explicity releases the lock.

Definition at line 101 of file Guard.h.

00102    {
00103       mLockStatus = false;
00104       return mTheLock->release();
00105    }


The documentation for this class was generated from the following file:
Generated on Sun May 2 14:47:11 2004 for VR Juggler Portable Runtime by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002