![]() |
mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
|
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. | |
Internal class for handling events.
| 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.
| continuation | Continuation to use for the event. |
| token_cancelable | Whether to respect the stop token of the continuation. |
| callback | Callback to run when the coroutine suspends. |
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.
| bool mrs_lib::coro::internal::EventState::is_ready | ( | ) |
Check if the event was already triggered.
| bool mrs_lib::coro::internal::EventState::try_cancel | ( | ) |
Try cancelling the event state.
The call will fail (return false) if the event was already triggered or cancelled.
| bool mrs_lib::coro::internal::EventState::try_trigger | ( | ) |
Try triggering the event state.
The call will fail (return false) if the event was already triggered or cancelled.