#include <vpr/Sync/Mutex.h>
Public Member Functions | |
| MutexNSPR () | |
| Constructor. | |
| ~MutexNSPR () | |
| Destructor. | |
| vpr::ReturnStatus | acquire () |
| Locks this mutex. | |
| vpr::ReturnStatus | acquireRead () |
| Acquires a read lock. | |
| vpr::ReturnStatus | acquireWrite () |
| Acquires a write lock. | |
| vpr::ReturnStatus | tryAcquire () |
| Tries to acquire a lock on this mutex (does not block). | |
| vpr::ReturnStatus | tryAcquireRead () |
| Tries to acquire a read lock (does not block). | |
| vpr::ReturnStatus | tryAcquireWrite () |
| Tries to acquire a write lock (does not block). | |
| vpr::ReturnStatus | release () |
| Releases the mutex. | |
| int | test () const |
| Tests the current lock status. | |
Protected Member Functions | |
| MutexNSPR & | operator= (const MutexNSPR &r) |
| MutexNSPR (const MutexNSPR &) | |
Protected Attributes | |
| PRLock * | mMutex |
| Mutex variable for the class. | |
| int | mLocked |
| Hack used to implement mutex testing. | |
Friends | |
| class | CondVarNSPR |
This is typedef'd to vpr::Mutex.
Definition at line 69 of file MutexNSPR.h.
| vpr::MutexNSPR::MutexNSPR | ( | ) | [inline] |
Constructor.
Definition at line 78 of file MutexNSPR.h.
References vprASSERT.
00078 : mLocked(0) 00079 { 00080 // ----- Allocate the mutex ----- // 00081 mMutex = PR_NewLock(); 00082 vprASSERT(mMutex != NULL); 00083 }
| vpr::MutexNSPR::~MutexNSPR | ( | ) | [inline] |
Destructor.
Definition at line 91 of file MutexNSPR.h.
00092 { 00093 PR_DestroyLock(mMutex); 00094 }
| vpr::MutexNSPR::MutexNSPR | ( | const MutexNSPR & | ) | [inline, protected] |
| vpr::ReturnStatus vpr::MutexNSPR::acquire | ( | ) | [inline] |
Locks this mutex.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 107 of file MutexNSPR.h.
00108 { 00109 PR_Lock(mMutex); 00110 mLocked = 1; 00111 00112 return vpr::ReturnStatus(); 00113 }
| vpr::ReturnStatus vpr::MutexNSPR::acquireRead | ( | ) | [inline] |
Acquires a read lock.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 128 of file MutexNSPR.h.
00129 { 00130 return this->acquire(); 00131 }
| vpr::ReturnStatus vpr::MutexNSPR::acquireWrite | ( | ) | [inline] |
Acquires a write lock.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 146 of file MutexNSPR.h.
00147 { 00148 return this->acquire(); 00149 }
| vpr::ReturnStatus vpr::MutexNSPR::tryAcquire | ( | ) | [inline] |
Tries to acquire a lock on this mutex (does not block).
vpr::ReturnStatus::Fail is returned if another thread is holding the lock already.
Definition at line 162 of file MutexNSPR.h.
References vpr::ReturnStatus::Fail.
00163 { 00164 // XXX: Possible race condition exists in this function implementation 00165 if ( mLocked == 0 ) 00166 { 00167 this->acquire(); 00168 return vpr::ReturnStatus(); 00169 } 00170 else 00171 { 00172 return vpr::ReturnStatus(vpr::ReturnStatus::Fail); 00173 } 00174 }
| vpr::ReturnStatus vpr::MutexNSPR::tryAcquireRead | ( | ) | [inline] |
Tries to acquire a read lock (does not block).
vpr::ReturnStatus::Fail is returned if another thread is holding the lock already.
Definition at line 188 of file MutexNSPR.h.
00189 { 00190 return this->tryAcquire(); 00191 }
| vpr::ReturnStatus vpr::MutexNSPR::tryAcquireWrite | ( | ) | [inline] |
Tries to acquire a write lock (does not block).
vpr::ReturnStatus::Fail is returned if another thread is holding the lock already.
Definition at line 205 of file MutexNSPR.h.
00206 { 00207 return this->tryAcquire(); 00208 }
| vpr::ReturnStatus vpr::MutexNSPR::release | ( | ) | [inline] |
Releases the mutex.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 220 of file MutexNSPR.h.
References vpr::ReturnStatus::Fail.
Referenced by vpr::CondVarNSPR::setMutex().
00221 { 00222 mLocked = 0; 00223 if ( PR_Unlock(mMutex) == PR_SUCCESS ) 00224 { 00225 return vpr::ReturnStatus(); 00226 } 00227 else 00228 { 00229 return vpr::ReturnStatus(vpr::ReturnStatus::Fail); 00230 } 00231 }
| int vpr::MutexNSPR::test | ( | ) | const [inline] |
Tests the current lock status.
Definition at line 241 of file MutexNSPR.h.
Referenced by vpr::CondVarNSPR::test().
00242 { 00243 return mLocked; 00244 }
friend class CondVarNSPR [friend] |
Definition at line 249 of file MutexNSPR.h.
PRLock* vpr::MutexNSPR::mMutex [protected] |
Mutex variable for the class.
Definition at line 252 of file MutexNSPR.h.
Referenced by operator=().
int vpr::MutexNSPR::mLocked [protected] |
Hack used to implement mutex testing.
Definition at line 253 of file MutexNSPR.h.
Referenced by operator=().
1.5.1