SDL3pp
A slim C++ wrapper for SDL3
|
A means to serialize access to a resource between threads. More...
Public Member Functions | |
constexpr | Mutex (const MutexRaw resource) |
Constructs from MutexParam. More... | |
constexpr | Mutex (const Mutex &other)=delete |
Copy constructor. | |
constexpr | Mutex (Mutex &&other) |
Move constructor. | |
constexpr | Mutex (const MutexRef &other)=delete |
constexpr | Mutex (MutexRef &&other)=delete |
Mutex () | |
Create a new mutex. More... | |
~Mutex () | |
Destructor. | |
Mutex & | operator= (Mutex other) |
Assignment operator. | |
constexpr MutexRaw | get () const |
Retrieves underlying MutexRaw. | |
constexpr MutexRaw | release () |
Retrieves underlying MutexRaw and clear this. | |
constexpr auto | operator<=> (const Mutex &other) const =default |
Comparison. | |
constexpr bool | operator== (std::nullptr_t _) const |
Comparison. | |
constexpr | operator bool () const |
Converts to bool. | |
constexpr | operator MutexParam () const |
Converts to MutexParam. | |
void | Destroy () |
Destroy a mutex created with Mutex.Mutex(). More... | |
void | Lock () |
Lock the mutex. More... | |
void | TryLock () |
Try to lock a mutex without blocking. More... | |
void | Unlock () |
Unlock the mutex. More... | |
Mutexes (short for "mutual exclusion") are a synchronization primitive that allows exactly one thread to proceed at a time.
Wikipedia has a thorough explanation of the concept:
https://en.wikipedia.org/wiki/Mutex
|
inlineexplicitconstexpr |
resource | a MutexRaw to be wrapped. |
This assumes the ownership, call release() if you need to take back.
|
inline |
All newly-created mutexes begin in the unlocked state.
Calls to Mutex.Lock() will not return while the mutex is locked by another thread. See Mutex.TryLock() to attempt to lock without blocking.
SDL mutexes are reentrant.