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 (Mutex &&other) noexcept
 Move constructor.
 Mutex ()
 Create a new mutex.
 ~Mutex ()
 Destructor.
constexpr Mutexoperator= (Mutex &&other) noexcept
 Assignment operator.
Public Member Functions inherited from SDL::MutexBase
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 ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr ResourceBaseT (RawPointer resource)
 Constructs from resource pointer.
constexpr ResourceBaseT (std::nullptr_t)
 Constructs null/invalid.
constexpr ResourceBaseT (const ResourceBaseT &)=default
 Copy constructor.
constexpr ResourceBaseT (ResourceBaseT &&) noexcept=default
 Move constructor.
Public Member Functions inherited from SDL::ResourceBaseT< MutexRaw >
constexpr ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr operator bool () const
 Converts to bool.
constexpr auto operator<=> (const ResourceBaseT &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::ResourceBaseT< MutexRaw >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.
Protected Member Functions inherited from SDL::ResourceBaseT< MutexRaw >
constexpr ~ResourceBaseT ()=default
 Destructor.
constexpr ResourceBaseToperator= (const ResourceBaseT &)=default
 Assignment operator.

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: