34template <
typename RoutineType>
39 return RoutineType(std::coroutine_handle<routine_promise>::from_promise(*
this));
91 bool auto_resume =
true;
100 bool should_terminate =
false;
114 std::unordered_map<std::string, std::any>
state;
122 const bool sync_to_clock =
false;
130 uint64_t delay_amount = 0;
140 template <
typename T>
143 state[key] = std::make_any<T>(std::move(value));
155 template <
typename T>
158 auto it = state.find(key);
159 if (it != state.end()) {
161 return std::any_cast<T>(&it->second);
162 }
catch (
const std::bad_any_cast&) {
171 set_state(
"domain_error", awaiter_name +
": " + suggestion);
172 should_terminate =
true;
211 bool sync_to_clock =
true;
220 uint64_t next_sample = 0;
227 uint64_t next_buffer_cycle = 0;
280 bool sync_to_clock =
true;
295 uint64_t next_frame = 0;
330 uint64_t delay_amount = 0;
362 bool sync_to_clock =
true;
370 std::atomic<uint64_t> next_sample { 0 };
378 std::atomic<uint64_t> next_frame { 0 };
391 std::atomic<DelayContext> active_delay_context { DelayContext::NONE };
399 uint64_t sample_delay_amount { 0 };
407 uint64_t frame_delay_amount { 0 };
415 std::atomic<bool> sample_satisfied {
false };
423 std::atomic<bool> frame_satisfied {
false };
463 std::atomic<bool> armed {
false };
475 Event get_return_object();
485 void own(std::shared_ptr<Vruta::NetworkSource> source)
487 owned_sources.push_back(std::move(source));
Coroutine resumed by more than one clock.
Coroutine type for event-driven suspension.
Coroutine resumed when a caller-supplied condition becomes true.
A C++20 coroutine-based graphics processing task with frame-accurate timing.
A C++20 coroutine-based audio processing task with sample-accurate timing.
DelayContext
Discriminator for different temporal delay mechanisms.
Coroutine promise type for audio processing tasks with sample-accurate timing.
std::function< bool()> condition
Condition evaluated by the scheduler thread on each iteration.
Coroutine promise for routines suspended on an arbitrary boolean condition.
Coroutine promise for routines resumed by more than one clock.
void own(std::shared_ptr< Vruta::NetworkSource > source)
Transfer ownership of a NetworkSource to this coroutine frame.
std::vector< std::shared_ptr< Vruta::NetworkSource > > owned_sources
Coroutine-owned NetworkSource instances.
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.