#include <Pt/System/Mutex.h>
MutexLock class for Mutex. More...
Inherits NonCopyable.
Public Member Functions | |
MutexLock (Mutex &m, bool doLock=true, bool isLocked=false) | |
Construct to guard a Mutex. More... | |
~MutexLock () | |
Unlocks the mutex unless unlock() was called. | |
void | lock () |
Lock the mutex. | |
Mutex & | mutex () |
Returns the guarded the mutex object. | |
const Mutex & | mutex () const |
Returns the guarded the mutex object. | |
void | unlock () |
Unlock so that the destructor does not unlock. | |
The MutexLock class adds functionality for scoped locking. In the constructor of a MutexLock, the mutex is locked and in the destructor it is unlocked. This way if for example an exception occures in the protected section the Mutex will be unlocked during stack unwinding when the MutexLock is destructed.