mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::coro::internal::EventState Class Reference

Internal class for handling events. More...

#include <event.hpp>

Public Member Functions

bool try_trigger ()
 Try triggering the event state.
 
bool try_cancel ()
 Try cancelling the event state.
 
bool add_continuation (CancellableContinuation continuation, bool token_cancelable, std::function< void()> callback)
 Store or resume the continuation as target for this event.
 
bool is_ready ()
 Check if the event was already triggered.
 

Detailed Description

Internal class for handling events.

Member Function Documentation

◆ add_continuation()

bool mrs_lib::coro::internal::EventState::add_continuation ( CancellableContinuation  continuation,
bool  token_cancelable,
std::function< void()>  callback 
)

Store or resume the continuation as target for this event.

Parameters
continuationContinuation to use for the event.
token_cancelableWhether to respect the stop token of the continuation.
callbackCallback to run when the coroutine suspends.
Returns
value to return from await_suspend

If the state was not yet triggered nor cancelled, the continuation is stored and resumed/canceled when the respective event comes. The callback is called only in this case.

If the event was already triggered, it will return to not suspend.

If the event was already cancelled, the continuation will be cancelled immediately.

◆ is_ready()

bool mrs_lib::coro::internal::EventState::is_ready ( )

Check if the event was already triggered.

Returns
true if event was already triggered, false otherwise.
Note
If the event was cancelled, this will return false.

◆ try_cancel()

bool mrs_lib::coro::internal::EventState::try_cancel ( )

Try cancelling the event state.

Returns
true if succeeded, false otherwise

The call will fail (return false) if the event was already triggered or cancelled.

◆ try_trigger()

bool mrs_lib::coro::internal::EventState::try_trigger ( )

Try triggering the event state.

Returns
true if succeeded, false otherwise

The call will fail (return false) if the event was already triggered or cancelled.


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