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

A means to block multiple threads until a condition is satisfied. More...

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

Public Member Functions

constexpr Condition (std::nullptr_t) noexcept
 Default ctor.
 
constexpr Condition (const ConditionRaw resource) noexcept
 Constructs from ConditionParam. More...
 
constexpr Condition (Condition &&other) noexcept
 Move constructor.
 
constexpr Condition (const ConditionRef &other)=delete
 
constexpr Condition (ConditionRef &&other)=delete
 
 Condition ()
 Create a condition variable. More...
 
 ~Condition ()
 Destructor.
 
constexpr Conditionoperator= (Condition &&other) noexcept
 Assignment operator.
 
constexpr ConditionRaw get () const noexcept
 Retrieves underlying ConditionRaw.
 
constexpr ConditionRaw release () noexcept
 Retrieves underlying ConditionRaw and clear this.
 
constexpr auto operator<=> (const Condition &other) const noexcept=default
 Comparison.
 
constexpr operator bool () const noexcept
 Converts to bool.
 
constexpr operator ConditionParam () const noexcept
 Converts to ConditionParam.
 
void Destroy ()
 Destroy a condition variable. More...
 
void Signal ()
 Restart one of the threads that are waiting on the condition variable. More...
 
void Broadcast ()
 Restart all threads that are waiting on the condition variable. More...
 
void Wait (MutexParam mutex)
 Wait until a condition variable is signaled. More...
 
bool WaitTimeout (MutexParam mutex, std::chrono::milliseconds timeout)
 Wait until a condition variable is signaled or a certain time has passed. More...
 

Protected Member Functions

constexpr Condition (const Condition &other) noexcept=default
 Copy constructor.
 
constexpr Conditionoperator= (const Condition &other) noexcept=default
 Assignment operator.
 

Detailed Description

Condition variables, paired with an Mutex, let an app halt multiple threads until a condition has occurred, at which time the app can release one or all waiting threads.

Wikipedia has a thorough explanation of the concept:

https://en.wikipedia.org/wiki/Condition_variable

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

Constructor & Destructor Documentation

◆ Condition() [1/2]

constexpr SDL::Condition::Condition ( const ConditionRaw  resource)
inlineexplicitconstexprnoexcept
Parameters
resourcea ConditionRaw to be wrapped.

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

◆ Condition() [2/2]

SDL::Condition::Condition ( )
inline
Postcondition
a new condition variable or nullptr on failure; call GetError() for more information.
Since
This function is available since SDL 3.2.0.
See also
Condition.Broadcast
Condition.Signal
Condition.Wait
Condition.WaitTimeout
Condition.Destroy

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