MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Vruta::conditional_promise Struct Reference

Coroutine promise for routines suspended on an arbitrary boolean condition. More...

#include <Promise.hpp>

+ Inheritance diagram for MayaFlux::Vruta::conditional_promise:
+ Collaboration diagram for MayaFlux::Vruta::conditional_promise:

Public Member Functions

FreeRoutine get_return_object ()
 
- Public Member Functions inherited from MayaFlux::Vruta::routine_promise< FreeRoutine >
void domain_mismatch_error (const std::string &awaiter_name, const std::string &suggestion)
 
CompletionAwaiter final_suspend () noexcept
 Determines whether the coroutine suspends before destruction.
 
FreeRoutine get_return_object ()
 
T * get_state (const std::string &key)
 Retrieves a value from the state dictionary.
 
std::suspend_never initial_suspend ()
 Determines whether the coroutine suspends immediately upon creation.
 
void notify_complete () noexcept
 
void on_complete (std::function< void()> callback)
 
void return_void ()
 Handles the coroutine's void return.
 
void set_should_terminate (bool value) noexcept
 
void set_state (const std::string &key, T value)
 Stores a value in the state dictionary.
 
void unhandled_exception ()
 Handles exceptions thrown from within the coroutine.
 

Public Attributes

std::atomic< bool > armed { false }
 True while the coroutine is suspended on a ConditionAwaiter.
 
std::function< bool()> condition
 Condition evaluated by the scheduler thread on each iteration.
 
ProcessingToken processing_token { ProcessingToken::CONDITIONAL }
 
- Public Attributes inherited from MayaFlux::Vruta::routine_promise< FreeRoutine >
bool auto_resume
 Flag indicating whether the coroutine should be automatically resumed.
 
std::function< void()> completion_callback
 
std::atomic< bool > completion_notified
 
std::atomic< bool > completion_registered
 
std::atomic< bool > completion_signaled
 
uint64_t delay_amount
 Amount of delay requested by the coroutine.
 
const ProcessingToken processing_token
 Token indicating how this coroutine should be processed.
 
std::atomic< bool > should_terminate
 Flag indicating whether the coroutine should be terminated.
 
std::unordered_map< std::string, std::any > state
 Dictionary for storing arbitrary state data.
 
const bool sync_to_clock
 Flag indicating whether the coroutine should synchronize with the audio clock.
 

Detailed Description

Coroutine promise for routines suspended on an arbitrary boolean condition.

FreeRoutine coroutines carry no clock. The scheduler's dedicated CONDITIONAL thread evaluates the stored condition on every iteration; when it returns true the handle is resumed. DelayContext stays NONE throughout because no delay is being modelled - the coroutine is simply waiting for a predicate to become satisfied.

The condition is written by ConditionAwaiter::await_suspend and read by the scheduler thread. Both accesses are on different threads, so the condition field is protected by the same atomic flag pattern used in BroadcastSource: the awaiter stores condition + handle atomically before setting armed, and the scheduler thread reads only after observing armed == true.

Definition at line 484 of file Promise.hpp.


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