Sunshine master
Self-hosted game stream host for Moonlight.
safe::alarm_raw_t< T > Class Template Reference

Alarm primitive used to wait for and raise shutdown-style signals. More...

#include <src/thread_safe.h>

Public Types

using status_t = util::optional_t<T>
 Status value carried by the alarm.
 

Public Member Functions

void reset ()
 Reset the object to its initial empty state.
 
void ring (const status_t &status)
 Mark the alarm as rung and wake waiting threads.
 
void ring (status_t &&status)
 Mark the alarm as rung and wake waiting threads.
 
status_tstatus ()
 Return or update the current status value.
 
const status_tstatus () const
 Return or update the current status value.
 
auto wait ()
 Block until the event is raised.
 
template<class Pred >
auto wait (Pred &&pred)
 Block until the event is raised and the predicate accepts the state.
 
template<class Rep , class Period >
auto wait_for (const std::chrono::duration< Rep, Period > &rel_time)
 Wait for for.
 
template<class Rep , class Period , class Pred >
auto wait_for (const std::chrono::duration< Rep, Period > &rel_time, Pred &&pred)
 Wait for for.
 
template<class Rep , class Period >
auto wait_until (const std::chrono::duration< Rep, Period > &rel_time)
 Wait for until.
 
template<class Rep , class Period , class Pred >
auto wait_until (const std::chrono::duration< Rep, Period > &rel_time, Pred &&pred)
 Wait for until.
 

Detailed Description

template<class T>
class safe::alarm_raw_t< T >

Alarm primitive used to wait for and raise shutdown-style signals.

Member Function Documentation

◆ ring() [1/2]

template<class T >
void safe::alarm_raw_t< T >::ring ( const status_t & status)
inline

Mark the alarm as rung and wake waiting threads.

Parameters
statusNative status code returned by the platform API.

◆ ring() [2/2]

template<class T >
void safe::alarm_raw_t< T >::ring ( status_t && status)
inline

Mark the alarm as rung and wake waiting threads.

Parameters
statusNative status code returned by the platform API.

◆ status() [1/2]

template<class T >
status_t & safe::alarm_raw_t< T >::status ( )
inline

Return or update the current status value.

Returns
Status status.

◆ status() [2/2]

template<class T >
const status_t & safe::alarm_raw_t< T >::status ( ) const
inline

Return or update the current status value.

Returns
Status status.

◆ wait() [1/2]

template<class T >
auto safe::alarm_raw_t< T >::wait ( )
inline

Block until the event is raised.

Returns
Lock object held after the event is observed.

◆ wait() [2/2]

template<class T >
template<class Pred >
auto safe::alarm_raw_t< T >::wait ( Pred && pred)
inline

Block until the event is raised and the predicate accepts the state.

Parameters
predPredicate used to decide whether the wait is complete.
Returns
Lock object held after the predicate succeeds.

◆ wait_for() [1/2]

template<class T >
template<class Rep , class Period >
auto safe::alarm_raw_t< T >::wait_for ( const std::chrono::duration< Rep, Period > & rel_time)
inline

Wait for for.

Parameters
rel_timeRel time.
Returns
Wait result indicating whether the condition was satisfied before timeout.

◆ wait_for() [2/2]

template<class T >
template<class Rep , class Period , class Pred >
auto safe::alarm_raw_t< T >::wait_for ( const std::chrono::duration< Rep, Period > & rel_time,
Pred && pred )
inline

Wait for for.

Parameters
rel_timeRel time.
predPredicate used to decide whether the wait is complete.
Returns
Wait result indicating whether the condition was satisfied before timeout.

◆ wait_until() [1/2]

template<class T >
template<class Rep , class Period >
auto safe::alarm_raw_t< T >::wait_until ( const std::chrono::duration< Rep, Period > & rel_time)
inline

Wait for until.

Parameters
rel_timeRel time.
Returns
Wait result indicating whether the condition was satisfied before the deadline.

◆ wait_until() [2/2]

template<class T >
template<class Rep , class Period , class Pred >
auto safe::alarm_raw_t< T >::wait_until ( const std::chrono::duration< Rep, Period > & rel_time,
Pred && pred )
inline

Wait for until.

Parameters
rel_timeRel time.
predPredicate used to decide whether the wait is complete.
Returns
Wait result indicating whether the condition was satisfied before the deadline.

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