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>
75 class MutexImpl* _impl;
138 , _isLocked(isLocked)
148 _mutex.unlockNoThrow();
192 class MutexImpl* _impl;
216 bool unlockNoThrow();
235 , _isLocked(isLocked)
245 _mutex.unlockNoThrow();
329 bool unlockNoThrow();
333 class ReadWriteMutexImpl* _impl;
362 _mutex.unlockNoThrow();
420 _mutex.unlockNoThrow();
511 bool testIsLocked()
const
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
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
void unlock()
Unlock so that the destructor does not unlock.
Definition Mutex.h:163
void lock()
Lock the mutex.
Definition Mutex.h:153
MutexLock(Mutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a Mutex.
Definition Mutex.h:136
~MutexLock()
Unlocks the mutex unless unlock() was called.
Definition Mutex.h:145
Mutual exclusion device.
Definition Mutex.h:73
Mutex()
Default constructor.
void unlock()
Unlocks the mutex.
void lock()
Lock the mutex.
bool tryLock()
Tries to lock the mutex.
bool unlockNoThrow()
Unlocks the mutex.
ReadLock(ReadWriteMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a ReadWriteMutex.
Definition Mutex.h:350
void unlock()
Unlocks the mutex.
Definition Mutex.h:376
~ReadLock()
Unlocks the mutex unless unlock() was called.
Definition Mutex.h:359
void lock()
Locks the mutex.
Definition Mutex.h:366
ReadWriteMutex & mutex()
Returns the guarded the mutex object.
Definition Mutex.h:386
Mutex for concurrent readers or one writer.
Definition Mutex.h:286
void writeLock()
Acquires a write lock.
~ReadWriteMutex()
Destructor.
ReadWriteMutex()
Constructor.
void unlock()
Releases the read or write lock.
bool tryReadLock()
Tries to acquire a read lock.
void readLock()
Acquires a read lock.
bool tryWriteLock()
Tries to acquire a write lock.
RecursiveLock(RecursiveMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a RecursiveMutex.
Definition Mutex.h:233
void unlock()
Unlocks the mutex.
Definition Mutex.h:259
RecursiveMutex & mutex()
Returns the guarded the mutex object.
Definition Mutex.h:269
void lock()
Locks the mutex.
Definition Mutex.h:249
~RecursiveLock()
Unlocks the mutex unless unlock() was called.
Definition Mutex.h:242
const RecursiveMutex & mutex() const
Returns the guarded the mutex object.
Definition Mutex.h:273
Recursive mutual exclusion device.
Definition Mutex.h:190
RecursiveMutex()
Constructor.
void unlock()
Unlocks the mutex.
void lock()
Locks the mutex.
bool tryLock()
Returns true if the mutex could be locked..
~RecursiveMutex()
Destructor.
~SpinLock()
Unlocks the mutex unless unlock() was called.
Definition Mutex.h:541
void unlock()
Unlocks the mutex.
Definition Mutex.h:558
SpinLock(SpinMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a SpinMutex.
Definition Mutex.h:532
void lock()
Locks the mutex.
Definition Mutex.h:548
Spin mutex.
Definition Mutex.h:465
~SpinMutex()
Destructor.
Definition Mutex.h:473
void unlock()
Unlocks the mutex.
Definition Mutex.h:504
SpinMutex()
Default Constructor.
Definition Mutex.h:468
void lock()
Lock the mutex.
Definition Mutex.h:484
bool tryLock()
Tries to acquire a lock.
Definition Mutex.h:498
static void yield()
Yield CPU time.
~WriteLock()
Unlocks the mutex unless unlock() was called.
Definition Mutex.h:417
WriteLock(ReadWriteMutex &m, bool doLock=true, bool isLocked=false)
Construct to guard a ReadWriteMutex.
Definition Mutex.h:408
void unlock()
Unlocks the mutex.
Definition Mutex.h:434
void lock()
Locks the mutex.
Definition Mutex.h:424
ReadWriteMutex & mutex()
Returns the guarded the mutex object.
Definition Mutex.h:444
int atomicCompareExchange(volatile atomic_t &val, int exch, int comp)
Performs an atomic compare-and-exchange operation.
int atomicExchange(volatile atomic_t &val, int exch)
Performs an atomic exchange operation.
int atomicGet(volatile atomic_t &val)
Atomically get a value.
System programming
Definition Connection.h:26
Core module.
Definition Allocator.h:33
Atomic integers to be used with atomicity functions.
Definition Atomicity.h:52