#include <vpr/Sync/CondVar.h>
Collaboration diagram for vpr::CondVarNSPR:

Public Member Functions | |
| CondVarNSPR (MutexNSPR *mutex=NULL) | |
| Constructor. | |
| ~CondVarNSPR () | |
| Destructor. | |
| vpr::ReturnStatus | wait (vpr::Interval timeToWait=vpr::Interval::NoTimeout) |
| Blocks on a condition. | |
| vpr::ReturnStatus | signal () |
| Signals another thread waiting on this condition variable. | |
| vpr::ReturnStatus | broadcast () |
| Signals all threads waiting on the condition variable. | |
| vpr::ReturnStatus | acquire () |
| Acquires a lock on the mutex variable associated with the condition variable. | |
| vpr::ReturnStatus | tryAcquire () |
| Tries to acquire a lock on the mutex variable associated with the condition variable. | |
| vpr::ReturnStatus | release () |
| Releases the lock on the mutex variable associated with the condition variable. | |
| void | setMutex (MutexNSPR *mutex) |
| Changes the condition variable mutex to be the specifiec mutex variable. | |
| int | test () |
| Tests the mutex to see if it is held. | |
| void | dump () const |
| Prints out information about the condition variable to stderr. | |
This is typedef'd to vpr::CondVar.
Definition at line 70 of file CondVarNSPR.h.
| vpr::CondVarNSPR::CondVarNSPR | ( | MutexNSPR * | mutex = NULL |
) | [inline] |
Constructor.
| mutex | Pointer to a vpr::MutexNSPR variable that is used in association with the condition variable in this class (optional). |
Definition at line 84 of file CondVarNSPR.h.
References vprASSERT.
00085 { 00086 // If the caller did not specify a mutex variable to use with 00087 // the condition variable, use mDefaultMutex. 00088 if ( mutex == NULL ) 00089 { 00090 mCondMutex = &mDefaultMutex; 00091 } 00092 else 00093 { 00094 mCondMutex = mutex; 00095 } 00096 00097 // Initialize the condition variable. 00098 mCondVar = PR_NewCondVar(mCondMutex->mMutex); 00099 00100 vprASSERT(mCondVar != NULL); 00101 }
| vpr::CondVarNSPR::~CondVarNSPR | ( | ) | [inline] |
Destructor.
Definition at line 109 of file CondVarNSPR.h.
| vpr::ReturnStatus vpr::CondVarNSPR::wait | ( | vpr::Interval | timeToWait = vpr::Interval::NoTimeout |
) | [inline] |
Blocks on a condition.
The lock asociated with this condition variable must be held prior to invoking this method. When invoked, the lock on the variable is released, and the calling thread is blocked until another thread informs it that the condition has changed or until the timeout expires.
vpr::ReturnStatus::Fail is returned if something went wrong in blocking on the condition.
Definition at line 131 of file CondVarNSPR.h.
References vpr::ReturnStatus::Fail, vpr::NSPR_getInterval(), vpr::ReturnStatus::setCode(), vpr::ReturnStatus::success(), and vprASSERT.
Referenced by vpr::ThreadNSPR::start().
00132 { 00133 vpr::ReturnStatus status; 00134 00135 // ASSERT: We have been locked. 00136 if ( PR_WaitCondVar(mCondVar, NSPR_getInterval(timeToWait)) != PR_SUCCESS ) 00137 { 00138 status.setCode(vpr::ReturnStatus::Fail); 00139 } 00140 00141 // XXX: Use error status to print a message before the assertion. 00142 vprASSERT(status.success()); 00143 00144 return status; 00145 }
| vpr::ReturnStatus vpr::CondVarNSPR::signal | ( | ) | [inline] |
Signals another thread waiting on this condition variable.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 158 of file CondVarNSPR.h.
References vpr::ReturnStatus::Fail, vpr::ReturnStatus::setCode(), vpr::ReturnStatus::success(), and vprASSERT.
00159 { 00160 vpr::ReturnStatus status; 00161 00162 // ASSERT: We have been locked 00163 if ( PR_NotifyCondVar(mCondVar) != PR_SUCCESS ) 00164 { 00165 status.setCode(vpr::ReturnStatus::Fail); 00166 } 00167 00168 vprASSERT(status.success()); 00169 00170 return status; 00171 }
| vpr::ReturnStatus vpr::CondVarNSPR::broadcast | ( | ) | [inline] |
Signals all threads waiting on the condition variable.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 185 of file CondVarNSPR.h.
References vpr::ReturnStatus::Fail, vpr::ReturnStatus::setCode(), vpr::ReturnStatus::success(), and vprASSERT.
00186 { 00187 vpr::ReturnStatus status; 00188 00189 // ASSERT: We have been locked 00190 if ( PR_NotifyAllCondVar(mCondVar) != PR_SUCCESS ) 00191 { 00192 status.setCode(vpr::ReturnStatus::Fail); 00193 } 00194 00195 vprASSERT(status.success()); 00196 00197 return status; 00198 }
| vpr::ReturnStatus vpr::CondVarNSPR::acquire | ( | ) | [inline] |
Acquires a lock on the mutex variable associated with the condition variable.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 213 of file CondVarNSPR.h.
Referenced by vpr::ThreadNSPR::start().
| vpr::ReturnStatus vpr::CondVarNSPR::tryAcquire | ( | ) | [inline] |
Tries to acquire a lock on the mutex variable associated with the condition variable.
vpr::ReturnStatus::Fail is returned if the lock is already held by another thread.
Definition at line 231 of file CondVarNSPR.h.
| vpr::ReturnStatus vpr::CondVarNSPR::release | ( | ) | [inline] |
Releases the lock on the mutex variable associated with the condition variable.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 246 of file CondVarNSPR.h.
Referenced by vpr::ThreadNSPR::start().
| void vpr::CondVarNSPR::setMutex | ( | MutexNSPR * | mutex | ) | [inline] |
Changes the condition variable mutex to be the specifiec mutex variable.
| mutex | Pointer to a vpr::MutexNSPR variable that is used in association with the condition variable in this class. |
Definition at line 264 of file CondVarNSPR.h.
References vpr::MutexNSPR::release().
00265 { 00266 // NOT exactly correct, but just make sure not to leave it locked 00267 mutex->release(); 00268 mCondMutex = mutex; 00269 }
| int vpr::CondVarNSPR::test | ( | ) | [inline] |
Tests the mutex to see if it is held.
Definition at line 272 of file CondVarNSPR.h.
References vpr::MutexNSPR::test().
| void vpr::CondVarNSPR::dump | ( | ) | const [inline] |
Prints out information about the condition variable to stderr.
Definition at line 283 of file CondVarNSPR.h.
00284 { 00285 std::cerr << "------------- vpr::CondVarNSPR::Dump ---------\n" 00286 << "Not Implemented yet.\n"; 00287 }
1.5.1