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

Coroutine resumed when a caller-supplied condition becomes true. More...

#include <Routine.hpp>

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

Public Types

using promise_type = MayaFlux::Vruta::conditional_promise
 

Public Member Functions

bool force_resume () override
 Force resume the coroutine, bypassing all checks Used only during shutdown to push coroutines to final_suspend.
 
 FreeRoutine (const FreeRoutine &other)=delete
 
 FreeRoutine (FreeRoutine &&other) noexcept
 
 FreeRoutine (std::coroutine_handle< promise_type > h)
 
bool get_auto_resume () const override
 Get auto_resume flag from promise.
 
uint64_t get_next_frame () const override
 Get next frame execution time (graphics domain)
 
uint64_t get_next_sample () const override
 Get next sample execution time (audio domain)
 
ProcessingToken get_processing_token () const override
 Get the processing token that determines how this routine should be scheduled.
 
bool get_should_terminate () const override
 Get should_terminate flag from promise.
 
bool get_sync_to_clock () const override
 Get sync_to_clock flag from promise.
 
bool initialize_state (uint64_t current_context=0U) override
 Initializes the coroutine's state for execution.
 
bool is_active () const override
 Checks if the coroutine is still active.
 
uint64_t next_execution () const override
 Gets the sample position when this routine should next execute.
 
FreeRoutineoperator= (const FreeRoutine &other)=delete
 
FreeRoutineoperator= (FreeRoutine &&other) noexcept
 
bool requires_clock_sync () const override
 Check if the routine should synchronize with a clock.
 
bool restart () override
 Restarts the coroutine from the beginning.
 
void set_auto_resume (bool v) override
 Set auto_resume flag in promise.
 
void set_next_frame (uint64_t) override
 Set next frame execution time (graphics domain)
 
void set_next_sample (uint64_t) override
 Set next sample execution time (audio domain)
 
void set_should_terminate (bool v) override
 Set should_terminate flag in promise.
 
bool try_resume (uint64_t current_context) override
 Attempts to resume the coroutine if it's ready to execute.
 
bool try_resume_with_context (uint64_t current_value, DelayContext context) override
 Attempts to resume the coroutine with explicit temporal context.
 
 ~FreeRoutine () override
 
- Public Member Functions inherited from MayaFlux::Vruta::Routine
virtual DelayContext get_delay_context () const
 Get the active delay context for this routine.
 
template<typename T >
T * get_state (const std::string &key)
 Gets a named state value from the coroutine.
 
virtual void set_delay_context (DelayContext)
 Set the active delay context for this routine.
 
template<typename T >
void set_state (const std::string &key, T value)
 Sets a named state value in the coroutine.
 
template<typename... Args>
void update_params (Args... args)
 Updates multiple named parameters in the coroutine's state.
 
virtual ~Routine ()=default
 Destructor.
 

Protected Member Functions

void * get_state_impl_raw (const std::string &key) override
 
void set_state_impl (const std::string &key, std::any value) override
 
- Protected Member Functions inherited from MayaFlux::Vruta::Routine
template<typename T >
T * get_state_impl (const std::string &key)
 Implementation helper for get_state.
 
virtual void update_params_impl ()
 brief Implementation helper for update_params
 
template<typename T , typename... Args>
void update_params_impl (const std::string &key, T value, Args... args)
 Implementation helper for update_params.
 

Private Attributes

std::coroutine_handle< promise_typem_handle
 

Detailed Description

Coroutine resumed when a caller-supplied condition becomes true.

FreeRoutine has no clock domain. It suspends on ConditionAwaiter, which stores a std::function<bool()> in the promise. The scheduler's dedicated CONDITIONAL thread evaluates that condition on every pass; the coroutine resumes on that thread the moment the condition returns true.

Intended for compute loops that must run independently of both the audio sample clock and the graphics frame clock - cellular automata, physics integration, ML inference, any free-running iterative process.

Usage:

auto my_routine = [&state]() -> Vruta::FreeRoutine {
while (true) {
co_await ConditionAwaiter{ [&]{ return state.ready.load(); } };
state.evolve();
}
};
scheduler->add_task(std::make_shared<FreeRoutine>(my_routine()), "ca_evolve");
Coroutine resumed when a caller-supplied condition becomes true.
Definition Routine.hpp:753

Definition at line 753 of file Routine.hpp.


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