SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL::Mutex Struct Reference

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

Inheritance diagram for SDL::Mutex:
[legend]

Public Member Functions

constexpr Mutex (MutexRaw resource) noexcept
 Constructs from raw Mutex.
constexpr Mutex (const Mutex &other)=delete
 Copy constructor.
constexpr Mutex (Mutex &&other) noexcept
 Move constructor.
constexpr Mutex (const MutexRef &other)=delete
constexpr Mutex (MutexRef &&other)=delete
 Mutex ()
 Create a new mutex.
 ~Mutex ()
 Destructor.
constexpr Mutexoperator= (Mutex &&other) noexcept
 Assignment operator.
Mutexoperator= (const Mutex &other)=delete
 Assignment operator.
void Destroy ()
 Destroy a mutex created with CreateMutex().
void Lock ()
 Lock the mutex.
bool TryLock ()
 Try to lock a mutex without blocking.
void Unlock ()
 Unlock the mutex.
constexpr ResourceBase (RawPointer resource)
 Constructs from resource pointer.
constexpr ResourceBase (std::nullptr_t=nullptr)
 Constructs null/invalid.
Public Member Functions inherited from SDL::ResourceBase< MutexRaw >
constexpr ResourceBase (RawPointer resource)
 Constructs from resource pointer.
constexpr operator bool () const
 Converts to bool.
constexpr auto operator<=> (const ResourceBase &other) const=default
 Comparison.
constexpr RawConstPointer operator-> () const noexcept
 member access to underlying resource pointer.
constexpr RawPointer get () const noexcept
 Retrieves underlying resource pointer.
constexpr RawPointer release () noexcept
 Retrieves underlying resource pointer and clear this.

Additional Inherited Members

Public Types inherited from SDL::ResourceBase< MutexRaw >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.

Detailed Description

A means to serialize access to a resource between threads.

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()

SDL::Mutex::Mutex ( MutexRaw resource)
inlineexplicitconstexprnoexcept

Constructs from raw Mutex.

Parameters
resourcea MutexRaw to be wrapped.

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


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