Regina Calculation Engine
|
A utility class for locking and unlocking a mutex. More...
#include <utilities/nthread.h>
Public Member Functions | |
MutexLock (const NMutex *mutex) | |
Creates a lock for the given mutex. More... | |
MutexLock (const NMutex &mutex) | |
Creates a lock for the given mutex. More... | |
~MutexLock () | |
Unlocks the mutex handled by this object. More... | |
A utility class for locking and unlocking a mutex.
A mutex is locked by simply declaring a local variable of type NMutex::MutexLock. The mutex will be unlocked when this variable goes out of scope.
|
inline |
Creates a lock for the given mutex.
If some other thread has already locked the given mutex, this thread will be suspended until the mutex is unlocked by the other thread. This thread will then lock the mutex itself.
mutex | the mutex to be locked by this object. This is const to simplify using mutex locks with data retrieval routines for subclasses of NMutex. |
|
inline |
Creates a lock for the given mutex.
If some other thread has already locked the given mutex, this thread will be suspended until the mutex is unlocked by the other thread. This thread will then lock the mutex itself.
mutex | the mutex to be locked by this object. This is const to simplify using mutex locks with data retrieval routines for subclasses of NMutex. |
|
inline |
Unlocks the mutex handled by this object.