SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::Mutex Class Reference

A means to serialize access to a resource between threads. More...

Inheritance diagram for SDL::Mutex:
Inheritance graph
[legend]

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.
 
Mutexoperator= (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...
 

Detailed Description

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

Since
This struct is available since SDL 3.2.0.
Category:
Resource

Constructor & Destructor Documentation

◆ Mutex() [1/2]

constexpr SDL::Mutex::Mutex ( const MutexRaw  resource)
inlineexplicitconstexpr
Parameters
resourcea MutexRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

◆ Mutex() [2/2]

SDL::Mutex::Mutex ( )
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.

Postcondition
the initialized and unlocked mutex or nullptr on failure; call GetError() for more information.
Since
This function is available since SDL 3.2.0.
See also
Mutex.Destroy
Mutex.Lock
Mutex.TryLock
Mutex.Unlock

The documentation for this class was generated from the following file: