|
SDL3pp
A slim C++ wrapper for SDL3
|
A means to serialize access to a resource between threads. More...

Public Member Functions | |
| constexpr | Mutex (std::nullptr_t) noexcept |
| Default ctor. | |
| constexpr | Mutex (const MutexRaw resource) noexcept |
| Constructs from MutexParam. More... | |
| constexpr | Mutex (Mutex &&other) noexcept |
| Move constructor. | |
| constexpr | Mutex (const MutexRef &other)=delete |
| constexpr | Mutex (MutexRef &&other)=delete |
| Mutex () | |
| Create a new mutex. More... | |
| ~Mutex () | |
| Destructor. | |
| constexpr Mutex & | operator= (Mutex &&other) noexcept |
| Assignment operator. | |
| constexpr MutexRaw | get () const noexcept |
| Retrieves underlying MutexRaw. | |
| constexpr MutexRaw | release () noexcept |
| Retrieves underlying MutexRaw and clear this. | |
| constexpr auto | operator<=> (const Mutex &other) const noexcept=default |
| Comparison. | |
| constexpr | operator bool () const noexcept |
| Converts to bool. | |
| constexpr | operator MutexParam () const noexcept |
| 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... | |
Protected Member Functions | |
| constexpr | Mutex (const Mutex &other) noexcept=default |
| Copy constructor. | |
| constexpr Mutex & | operator= (const Mutex &other) noexcept=default |
| Assignment operator. | |
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
|
inlineexplicitconstexprnoexcept |
| 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.