#include <Pt/System/Mutex.h>
Mutual exclusion device. More...
Inherits NonCopyable.
Public Member Functions | |
| Mutex () | |
| Default constructor. | |
| ~Mutex () | |
| Destructor. | |
| void | lock () |
| Lock the mutex. | |
| bool | tryLock () |
| Tries to lock the mutex. | |
| void | unlock () |
| Unlocks the mutex. | |
| bool | unlockNoThrow () |
| Unlocks the mutex. | |
Mutex serializes access to shared data. lock() waits if another thread holds it. The same thread must not lock it again. The mutex must be unlocked when it is destroyed.
MutexLock locks in the constructor and unlocks in the destructor, including during stack unwinding.
| ~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.