Attempts to resume the coroutine with explicit temporal context.
This context-aware resume method allows different temporal mechanisms to coexist within the same processing token. For example, both sample-based and buffer-cycle-based delays can use SAMPLE_ACCURATE token without interfering with each other.
469{
471 return false;
472
473 auto& promise_ref =
m_handle.promise();
474
475 if (promise_ref.should_terminate || !promise_ref.auto_resume) {
476 return false;
477 }
478
479 const DelayContext active = promise_ref.active_delay_context.load(std::memory_order_acquire);
480
483 }
484
486 return false;
487 }
488
490 if (promise_ref.sample_delay_amount > 0
491 && current_value >= promise_ref.next_sample.load(std::memory_order_acquire)) {
492 promise_ref.sample_satisfied.store(true, std::memory_order_release);
493 }
495 if (promise_ref.frame_delay_amount > 0
496 && current_value >= promise_ref.next_frame.load(std::memory_order_acquire)) {
497 promise_ref.frame_satisfied.store(true, std::memory_order_release);
498 }
499 }
500
501 bool sample_required = promise_ref.sample_delay_amount > 0;
502 bool frame_required = promise_ref.frame_delay_amount > 0;
503
504 if (sample_required && !promise_ref.sample_satisfied.load(std::memory_order_acquire)) {
505 return false;
506 }
507 if (frame_required && !promise_ref.frame_satisfied.load(std::memory_order_acquire)) {
508 return false;
509 }
510
512 if (!promise_ref.active_delay_context.compare_exchange_strong(
514 std::memory_order_acq_rel, std::memory_order_acquire)) {
515 return false;
516 }
517
518 promise_ref.sample_satisfied.store(false, std::memory_order_release);
519 promise_ref.frame_satisfied.store(false, std::memory_order_release);
520
522 return true;
523}
std::coroutine_handle< promise_type > m_handle
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.
DelayContext
Discriminator for different temporal delay mechanisms.
@ MULTIPLE
Armed on both sample and frame clocks; first to arrive resumes (CrossRoutine)
@ FRAME_BASED
Frame-rate delay (Graphics domain)
@ NONE
No active delay, try resume immediately.
@ SAMPLE_BASED
Sample-accurate delay (audio domain)
@ AWAIT
Awaiter-induced delay (temporary suspension)