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

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

Inheritance diagram for SDL::Condition:
[legend]

Public Member Functions

constexpr Condition (ConditionRaw resource) noexcept
 Constructs from raw Condition.
constexpr Condition (const Condition &other)=delete
 Copy constructor.
constexpr Condition (Condition &&other) noexcept
 Move constructor.
constexpr Condition (const ConditionRef &other)=delete
constexpr Condition (ConditionRef &&other)=delete
 Condition ()
 Create a condition variable.
 ~Condition ()
 Destructor.
constexpr Conditionoperator= (Condition &&other) noexcept
 Assignment operator.
Conditionoperator= (const Condition &other)=delete
 Assignment operator.
void Destroy ()
 Destroy a condition variable.
void Signal ()
 Restart one of the threads that are waiting on the condition variable.
void Broadcast ()
 Restart all threads that are waiting on the condition variable.
void Wait (MutexRef mutex)
 Wait until a condition variable is signaled.
bool WaitTimeout (MutexRef mutex, std::chrono::milliseconds timeout)
 Wait until a condition variable is signaled or a certain time has passed.
constexpr ResourceBase (RawPointer resource)
 Constructs from resource pointer.
constexpr ResourceBase (std::nullptr_t=nullptr)
 Constructs null/invalid.
Public Member Functions inherited from SDL::ResourceBase< ConditionRaw >
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< ConditionRaw >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.

Detailed Description

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

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

SDL::Condition::Condition ( ConditionRaw resource)
inlineexplicitconstexprnoexcept

Constructs from raw Condition.

Parameters
resourcea ConditionRaw 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: