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
Core module.
Definition: Allocator.h:33
Recursive mutual exclusion device.
Definition: Mutex.h:188
ReadWriteMutex()
Constructor.
void lock()
Locks the mutex.
Definition: Mutex.h:417
void unlock()
Unlocks the mutex.
ReadWriteMutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:381
void lock()
Lock the mutex.
Definition: Mutex.h:153
Mutex()
Default constructor.
ReadWriteMutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:437
~SpinMutex()
Destructor.
Definition: Mutex.h:468
~MutexLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:145
MutexLock class for Mutex.
Definition: Mutex.h:127
bool tryLock()
Tries to acquire a lock.
Definition: Mutex.h:493
Reader lock object for read-write mutexes.
Definition: Mutex.h:336
Spinmutex class.
Definition: Mutex.h:460
~ReadWriteMutex()
Destructor.
void unlock()
Unlocks the mutex.
Definition: Mutex.h:499
void readLock()
Acquires a read lock.
bool unlockNoThrow()
Unlocks the mutex.
void lock()
Locks the mutex.
Definition: Mutex.h:541
void unlock()
Unlocks the mutex.
Definition: Mutex.h:255
WriteLock(ReadWriteMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a ReadWriteMutex.
Definition: Mutex.h:401
void lock()
Lock the mutex.
Definition: Mutex.h:479
bool tryLock()
Tries to lock the mutex.
void unlock()
Unlocks the mutex.
Definition: Mutex.h:427
RecursiveMutex()
Constructor.
void lock()
Locks the mutex.
Lock class for recursive mutexes.
Definition: Mutex.h:220
~RecursiveMutex()
Destructor.
void writeLock()
Acquires a write lock.
bool tryLock()
Returns true if the mutex could be locked..
Mutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:173
const Mutex & mutex() const
Returns the guarded the mutex object.
Definition: Mutex.h:177
bool tryReadLock()
Tries to acquire a read lock.
~RecursiveLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:238
Mutual exclusion device.
Definition: Mutex.h:49
RecursiveMutex & mutex()
Returns the guarded the mutex object.
Definition: Mutex.h:265
RecursiveLock(RecursiveMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a RecursiveMutex.
Definition: Mutex.h:229
void lock()
Lock the mutex.
~WriteLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:410
void unlock()
Unlocks the mutex.
Definition: Mutex.h:371
Writer lock object for read-write mutexes.
Definition: Mutex.h:392
void lock()
Locks the mutex.
Definition: Mutex.h:361
~ReadLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:354
ReadLock(ReadWriteMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a ReadWriteMutex.
Definition: Mutex.h:345
void unlock()
Unlocks the mutex.
void lock()
Locks the mutex.
Definition: Mutex.h:245
SpinMutex()
Default Constructor.
Definition: Mutex.h:463
void unlock()
Releases the read or write lock.
bool tryWriteLock()
Tries to acquire a write lock.
Protects derived classes from being copied.
Definition: NonCopyable.h:54
~SpinLock()
Unlocks the mutex unless unlock() was called.
Definition: Mutex.h:534
Lock object for spin mutexes.
Definition: Mutex.h:516
void unlock()
Unlock so that the destructor does not unlock.
Definition: Mutex.h:163
Synchronisation device similar to a POSIX rwlock.
Definition: Mutex.h:283
static void yield()
Yield CPU time.
void unlock()
Unlocks the mutex.
Definition: Mutex.h:551
Atomic integers to be used with atomicity functions.
Definition: Atomicity.h:51
const RecursiveMutex & mutex() const
Returns the guarded the mutex object.
Definition: Mutex.h:269
SpinLock(SpinMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a SpinMutex.
Definition: Mutex.h:525
MutexLock(Mutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a Mutex.
Definition: Mutex.h:136