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

Coroutine promise for routines resumed by more than one clock. More...

#include <Promise.hpp>

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

Public Member Functions

CrossRoutine get_return_object ()
 
- Public Member Functions inherited from MayaFlux::Vruta::routine_promise< CrossRoutine >
void domain_mismatch_error (const std::string &awaiter_name, const std::string &suggestion)
 
std::suspend_always final_suspend () noexcept
 Determines whether the coroutine suspends before destruction.
 
CrossRoutine 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 return_void ()
 Handles the coroutine's void return.
 
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< DelayContextactive_delay_context { DelayContext::NONE }
 Active delay context controlling which pump(s) may resume this routine.
 
uint64_t frame_delay_amount { 0 }
 Number of frames requested by the current MultiRateDelay suspension.
 
std::atomic< bool > frame_satisfied { false }
 Set by the frame-clock pump when next_frame has been reached.
 
std::atomic< uint64_t > next_frame { 0 }
 Frame position at which the frame-clock pump should next resume this routine.
 
std::atomic< uint64_t > next_sample { 0 }
 Sample position at which the sample-clock pump should next resume this routine.
 
ProcessingToken processing_token { ProcessingToken::MULTI_RATE }
 Processing token identifying this coroutine as multi-rate.
 
uint64_t sample_delay_amount { 0 }
 Number of samples requested by the current MultiRateDelay suspension.
 
std::atomic< bool > sample_satisfied { false }
 Set by the sample-clock pump when next_sample has been reached.
 
bool sync_to_clock = true
 Whether this routine should synchronize with a clock on initialization.
 
- Public Attributes inherited from MayaFlux::Vruta::routine_promise< CrossRoutine >
bool auto_resume
 Flag indicating whether the coroutine should be automatically resumed.
 
uint64_t delay_amount
 Amount of delay requested by the coroutine.
 
const ProcessingToken processing_token
 Token indicating how this coroutine should be processed.
 
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 resumed by more than one clock.

A cross routine reports ProcessingToken::MULTI_RATE and lives in the single MULTI_RATE task list, which both the sample-clock pump (audio thread) and the frame-clock pump (graphics thread) scan. When suspended on a single-clock awaiter only the matching thread resumes it. When suspended on MultiRateDelay the context is MULTIPLE: both threads contribute, and the gate uses a compare-exchange on active_delay_context so exactly one thread fires the resume after all required clocks are satisfied.

active_delay_context, next_sample, next_frame, sample_satisfied, and frame_satisfied are read by both pumps concurrently with the await_suspend write, so they are atomic. The two delay-amount fields are written only in await_suspend and read only after the gate has claimed exclusivity, so they stay non-atomic.

Definition at line 351 of file Promise.hpp.


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