29 #ifndef Pt_System_Mutex_h
30 #define Pt_System_Mutex_h
32 #include <Pt/Atomicity.h>
33 #include <Pt/NonCopyable.h>
34 #include <Pt/System/Api.h>
35 #include <Pt/System/Thread.h>
51 class MutexImpl* _impl;
138 , _isLocked(isLocked)
190 class MutexImpl* _impl;
214 bool unlockNoThrow();
231 , _isLocked(isLocked)
241 _mutex.unlockNoThrow();
326 bool unlockNoThrow();
330 class ReadWriteMutexImpl* _impl;
357 _mutex.unlockNoThrow();
413 _mutex.unlockNoThrow();
482 while( atomicCompareExchange(_count, 1, 0) )
495 return ! atomicCompareExchange(_count, 1, 0);
502 atomicExchange(_count, 0);
506 bool testIsLocked()
const
507 {
return atomicGet(const_cast<volatile Pt::atomic_t&>(_count)) != 0; }
569 #endif // Pt_System_Mutex_h
Lock object for spin mutexes.
Definition: Mutex.h:515
void lock()
Locks the mutex.
Definition: Mutex.h:361
void lock()
Lock the mutex.
Definition: Mutex.h:153
Atomic integers to be used with atomicity functions.
Definition: Atomicity.h:50
~ReadLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:354
void lock()
Lock the mutex.
Protects derived classes from being copied.
Definition: NonCopyable.h:54
Recursive mutual exclusion device.
Definition: Mutex.h:187
SpinMutex()
Default Constructor.
Definition: Mutex.h:463
void unlock()
Unlocks the mutex.
Definition: Mutex.h:499
ReadLock(ReadWriteMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a ReadWriteMutex.
Definition: Mutex.h:345
void lock()
Locks the mutex.
Definition: Mutex.h:541
Synchronisation device similar to a POSIX rwlock.
Definition: Mutex.h:282
void lock()
Locks the mutex.
~SpinMutex()
Destructor.
Definition: Mutex.h:468
void writeLock()
Acquires a write lock.
void unlock()
Unlocks the mutex.
Definition: Mutex.h:255
void unlock()
Unlocks the mutex.
Definition: Mutex.h:371
static void yield()
Yield CPU time.
void unlock()
Unlocks the mutex.
void unlock()
Releases the read or write lock.
void lock()
Locks the mutex.
Definition: Mutex.h:417
bool tryLock()
Tries to acquire a lock.
Definition: Mutex.h:493
ReadWriteMutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:381
void unlock()
Unlock so that the destructor does not unlock.
Definition: Mutex.h:163
void unlock()
Unlocks the mutex.
Definition: Mutex.h:427
Mutual exclusion device.
Definition: Mutex.h:48
~WriteLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:410
bool unlockNoThrow()
Unlocks the mutex.
~MutexLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:145
Spinmutex class.
Definition: Mutex.h:459
void unlock()
Unlocks the mutex.
Definition: Mutex.h:551
Lock class for recursive mutexes.
Definition: Mutex.h:219
Reader lock object for read-write mutexes.
Definition: Mutex.h:335
~RecursiveLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:238
RecursiveMutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:265
SpinLock(SpinMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a SpinMutex.
Definition: Mutex.h:525
Mutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:173
MutexLock(Mutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a Mutex.
Definition: Mutex.h:136
void lock()
Locks the mutex.
Definition: Mutex.h:245
void lock()
Lock the mutex.
Definition: Mutex.h:479
~SpinLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:534
void unlock()
Unlocks the mutex.
void readLock()
Acquires a read lock.
RecursiveLock(RecursiveMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a RecursiveMutex.
Definition: Mutex.h:229
MutexLock class for Mutex.
Definition: Mutex.h:126
const Mutex & mutex() const
Returns the guarded the mutex object.
Definition: Mutex.h:177
const RecursiveMutex & mutex() const
Returns the guarded the mutex object.
Definition: Mutex.h:269
WriteLock(ReadWriteMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a ReadWriteMutex.
Definition: Mutex.h:401
ReadWriteMutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:437
Writer lock object for read-write mutexes.
Definition: Mutex.h:391