MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kriya::ConditionAwaiter Class Reference

Suspends a FreeRoutine until a caller-supplied predicate returns true. More...

#include <ConditionAwaiter.hpp>

+ Collaboration diagram for MayaFlux::Kriya::ConditionAwaiter:

Public Member Functions

bool await_ready () const
 Evaluate the condition before suspending.
 
void await_resume () const
 No value to return on resumption.
 
void await_suspend (std::coroutine_handle< Vruta::conditional_promise > handle)
 Arm the promise with the condition and the coroutine handle.
 
 ConditionAwaiter (std::function< bool()> condition)
 Construct with a condition predicate.
 

Private Attributes

std::function< bool()> m_condition
 

Detailed Description

Suspends a FreeRoutine until a caller-supplied predicate returns true.

await_ready() evaluates the condition immediately; if already true the coroutine does not suspend. Otherwise await_suspend() arms the promise so the scheduler's CONDITIONAL thread will evaluate the condition on each pass and resume the handle when it returns true.

The condition is moved into the promise on suspension and cleared on resumption. It must be safe to call from the scheduler thread.

auto routine = [&]() -> Vruta::FreeRoutine {
while (true) {
co_await ConditionAwaiter{ [&]{ return flag.load(); } };
do_work();
}
};
Suspends a FreeRoutine until a caller-supplied predicate returns true.
Coroutine resumed when a caller-supplied condition becomes true.
Definition Routine.hpp:753

Definition at line 28 of file ConditionAwaiter.hpp.


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