#include <Pt/System/Mutex.h>
Mutual exclusion device. More...
Inherits NonCopyable.
Public Member Functions | |
Mutex () | |
Default constructor. | |
~Mutex () | |
Destructor. More... | |
void | lock () |
Lock the mutex. More... | |
bool | tryLock () |
Tries to lock the mutex. More... | |
void | unlock () |
Unlocks the mutex. | |
bool | unlockNoThrow () |
Unlocks the mutex. More... | |
A Mutex is a mutual exclusion device. It is used to synchronize the access to data which is accessed by more than one thread or process at the same time. Mutexes are not recursive, that is the same thread can not lock a mutex multiple times without deadlocking.
~Mutex | ( | ) |
The destructor destroys the mutex. The mutex must be in unlocked state when the destructor is called.
void lock | ( | ) |
If the mutex is currently locked by another thread, the calling thread suspends until no other thread holds a lock on it. If the mutex is already locked by the calling thread a deadlock occurs.
bool tryLock | ( | ) |
If the mutex is currently locked by another thread, false is returned, otherwise the lock is acquired.
bool unlockNoThrow | ( | ) |
This method does not throw an exception if unlocking the mutex fails but simply returns false.