#include <mcllib/MCRWLock.h>
Inheritance diagram for MCRWLock:
Public Member Functions | |
bool | isLocked () const |
Test to see if the mutex is locked. | |
void | lock (bool reader) |
Lock the mutex. | |
void | lock () |
Read-lock the mutex. | |
MCRWLock (MCRWMutex *pMutex, bool reader, bool locked) | |
Construct a lock, optionally locking the provided mutex. | |
MCRWLock (MCRWMutex *pMutex, bool reader) | |
Construct a lock, locking the provided mutex. | |
MCRWLock (MCRWMutex *pMutex) | |
Construct a lock, read-locking the provided mutex. | |
void | unlock () |
Unlock the mutex. | |
~MCRWLock () | |
Unlock the mutex provided at construction if it is locked. |
Provides automatic locking and unlocking based on scope. Lock objects lock a readers/writer mutex (provided at construction time) and unlock the mutex at destruction. Methods are provided for locking and unlocking the mutex other than at construction/destruction. However the easiest way to use this object is in the automatic mode. This kind of scoped locking frees the developer from the need to worry about remembering to do an unlock for each lock.
|
Construct a lock, read-locking the provided mutex.
|
|
Construct a lock, locking the provided mutex.
|
|
Construct a lock, optionally locking the provided mutex.
|
|
Unlock the mutex provided at construction if it is locked. This provides for scoped locking. When the lock object goes out of scope, the mutex is unlocked if it was locked. This prevents mutexes being held onto inadvertently |
|
Test to see if the mutex is locked.
|
|
Lock the mutex. If the mutex is already locked a fatal exception is thrown. This is indicative of an application programming error. lock() waits indefinitely until the mutex becomes available.
|
|
Read-lock the mutex. If the mutex is already locked a fatal exception is thrown. This is indicative of an application programming error. lock() waits indefinitely until the mutex becomes available. |
|
Unlock the mutex. If the mutex is already unlocked a fatal exception is thrown. This is indicative of an application programming error. One or more waiting threads will be eligible to lock the mutex depending one the kind of lock they are attempting. |