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

Handle to a non owned mutex. More...

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

Public Member Functions

constexpr MutexRef (const MutexRef &other)
 Copy constructor.
 
constexpr MutexRef (MutexRef &&other)
 Move constructor.
 
constexpr ~MutexRef ()=default
 Default constructor.
 
MutexRefoperator= (MutexRef other)
 Assignment operator.
 
void reset (SDL_Mutex *newResource={})
 Destroy a mutex created with MutexBase.MutexBase().
 
 MutexBase ()
 Create a new mutex.
 
- Public Member Functions inherited from SDL::MutexBase
 MutexBase ()
 Create a new mutex.
 
void Lock ()
 Lock the mutex.
 
void TryLock ()
 Try to lock a mutex without blocking.
 
void Unlock ()
 Unlock the mutex.
 
constexpr Resource (T resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
- Public Member Functions inherited from SDL::Resource< SDL_Mutex * >
constexpr Resource (SDL_Mutex * resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
Resourceoperator= (const Resource &other)=delete
 
Resourceoperator= (Resource &&other)=delete
 
constexpr operator bool () const
 True if contains a valid resource.
 
constexpr bool operator== (const Resource &other) const=default
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr SDL_Mutex * get () const
 Return contained resource;.
 
constexpr SDL_Mutex * release (SDL_Mutex * newResource={})
 Return contained resource and empties or replace value.
 
constexpr const SDL_Mutex * operator-> () const
 Access to fields.
 
constexpr SDL_Mutex * operator-> ()
 Access to fields.
 

Detailed Description

Category:
Resource
See also
MutexBase
Mutex

Member Function Documentation

◆ MutexBase()

SDL::MutexBase::MutexBase ( )
inline

All newly-created mutexes begin in the unlocked state.

Calls to MutexBase.Lock() will not return while the mutex is locked by another thread. See MutexBase.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
MutexBase.Lock
MutexBase.TryLock
MutexBase.Unlock

◆ reset()

void SDL::MutexRef::reset ( SDL_Mutex *  newResource = {})
inline

This function must be called on any mutex that is no longer needed. Failure to destroy a mutex will result in a system memory or resource leak. While it is safe to destroy a mutex that is unlocked, it is not safe to attempt to destroy a locked mutex, and may result in undefined behavior depending on the platform.

Since
This function is available since SDL 3.2.0.
See also
MutexBase.MutexBase

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