vpr::ReadGuard Class Reference

Read Guard wrapper. More...

#include <vpr/Sync/RWGuard.h>

Collaboration diagram for vpr::ReadGuard:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ReadGuard (RWMutex &lock, int block=1)
 Acquires the lock implicitly.
 ~ReadGuard ()
 Releases the lock.
const bool & locked ()
 
Returns:
true is returned if this guard is locked.

vpr::ReturnStatus acquire ()
 Acquires the lock.
vpr::ReturnStatus tryAcquire ()
 Tries to acquire the lock.
vpr::ReturnStatus release ()
 Explicity releases the lock.

Detailed Description

Read Guard wrapper.

Definition at line 57 of file RWGuard.h.


Constructor & Destructor Documentation

vpr::ReadGuard::ReadGuard ( RWMutex lock,
int  block = 1 
) [inline]

Acquires the lock implicitly.

If block is 1, then use a blocking acquire.

Definition at line 64 of file RWGuard.h.

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

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

vpr::ReadGuard::~ReadGuard (  )  [inline]

Releases the lock.

Definition at line 70 of file RWGuard.h.

References vpr::RWMutexPosix::release().

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


Member Function Documentation

const bool& vpr::ReadGuard::locked (  )  [inline]

Returns:
true is returned if this guard is locked.

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

Definition at line 82 of file RWGuard.h.

00083    {
00084       return mLockStatus;
00085    }

vpr::ReturnStatus vpr::ReadGuard::acquire (  )  [inline]

Acquires the lock.

Definition at line 88 of file RWGuard.h.

References vpr::RWMutexPosix::acquireRead(), and vpr::ReturnStatus::success().

Referenced by ReadGuard().

00089    {
00090       vpr::ReturnStatus status = mTheLock->acquireRead();
00091       mLockStatus = status.success();
00092       return status;
00093    }

vpr::ReturnStatus vpr::ReadGuard::tryAcquire (  )  [inline]

Tries to acquire the lock.

Definition at line 96 of file RWGuard.h.

References vpr::ReturnStatus::success(), and vpr::RWMutexPosix::tryAcquireRead().

Referenced by ReadGuard().

00097    {
00098       vpr::ReturnStatus status = mTheLock->tryAcquireRead();
00099       mLockStatus = status.success();
00100       return status;
00101    }

vpr::ReturnStatus vpr::ReadGuard::release (  )  [inline]

Explicity releases the lock.

Definition at line 104 of file RWGuard.h.

References vpr::RWMutexPosix::release().

00105    {
00106       mLockStatus = false;
00107       return mTheLock->release();
00108    }


The documentation for this class was generated from the following file:
Generated on Thu Jan 4 10:55:52 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1