32template <
typename RoutineType>
37 return RoutineType(std::coroutine_handle<routine_promise>::from_promise(*
this));
89 bool auto_resume =
true;
98 bool should_terminate =
false;
112 std::unordered_map<std::string, std::any>
state;
120 const bool sync_to_clock =
false;
128 uint64_t delay_amount = 0;
138 template <
typename T>
141 state[key] = std::make_any<T>(std::move(value));
153 template <
typename T>
156 auto it = state.find(key);
157 if (it != state.end()) {
159 return std::any_cast<T>(&it->second);
160 }
catch (
const std::bad_any_cast&) {
169 set_state(
"domain_error", awaiter_name +
": " + suggestion);
170 should_terminate =
true;
Multi-domain coroutine that can handle multiple processing rates.
Coroutine type for event-driven suspension.
A C++20 coroutine-based graphics processing task with frame-accurate timing.
A C++20 coroutine-based audio processing task with sample-accurate timing.
@ MULTI_RATE
Coroutine can handle multiple sample rates. Picks the frame-accurate processing token by default.
@ EVENT_DRIVEN
Event-driven execution - process when events arrive.
@ FRAME_ACCURATE
Coroutine is frame-accurate.
@ SAMPLE_ACCURATE
Coroutine is sample-accurate.
DelayContext
Discriminator for different temporal delay mechanisms.
@ NONE
No active delay, resume immediately.
uint64_t next_sample
The sample position when this coroutine should next execute.
ProcessingToken processing_token
uint64_t next_buffer_cycle
The buffer cycle when this coroutine should next execute Managed by BufferDelay awaiter.
SoundRoutine get_return_object()
Creates the SoundRoutine object returned to the caller.
DelayContext active_delay_context
The active delay context for this coroutine.
Coroutine promise type for audio processing tasks with sample-accurate timing.
ComplexRoutine get_return_object()
ProcessingToken processing_token
Coroutine promise type for complex processing tasks with multi-rate scheduling.
Event get_return_object()
ProcessingToken processing_token
GraphicsRoutine get_return_object()
Creates the GraphicsRoutine object returned to the caller.
DelayContext active_delay_context
The active delay context for this coroutine.
uint64_t delay_amount
The amount of delay units for incremental delays.
uint64_t next_frame
The frame position when this coroutine should next execute.
bool sync_to_clock
Whether this routine should synchronize with FrameClock.
ProcessingToken processing_token
Processing token indicating frame-accurate scheduling.
Coroutine promise type for graphics processing tasks with frame-accurate timing.
void unhandled_exception()
Handles exceptions thrown from within the coroutine.
void domain_mismatch_error(const std::string &awaiter_name, const std::string &suggestion)
void set_state(const std::string &key, T value)
Stores a value in the state dictionary.
RoutineType get_return_object()
T * get_state(const std::string &key)
Retrieves a value from the state dictionary.
void return_void()
Handles the coroutine's void return.
std::unordered_map< std::string, std::any > state
Dictionary for storing arbitrary state data.
std::suspend_never initial_suspend()
Determines whether the coroutine suspends immediately upon creation.
std::suspend_always final_suspend() noexcept
Determines whether the coroutine suspends before destruction.
Base coroutine promise type for audio processing tasks.