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.
482{
484 return false;
485
486 auto& promise_ref =
m_handle.promise();
487
488 if (promise_ref.should_terminate || !promise_ref.auto_resume) {
489 return false;
490 }
491
492 const DelayContext active = promise_ref.active_delay_context.load(std::memory_order_acquire);
493
496 }
497
499 return false;
500 }
501
503 if (promise_ref.sample_delay_amount > 0
504 && current_value >= promise_ref.next_sample.load(std::memory_order_acquire)) {
505 promise_ref.sample_satisfied.store(true, std::memory_order_release);
506 }
508 if (promise_ref.frame_delay_amount > 0
509 && current_value >= promise_ref.next_frame.load(std::memory_order_acquire)) {
510 promise_ref.frame_satisfied.store(true, std::memory_order_release);
511 }
512 }
513
514 bool sample_required = promise_ref.sample_delay_amount > 0;
515 bool frame_required = promise_ref.frame_delay_amount > 0;
516
517 if (sample_required && !promise_ref.sample_satisfied.load(std::memory_order_acquire)) {
518 return false;
519 }
520 if (frame_required && !promise_ref.frame_satisfied.load(std::memory_order_acquire)) {
521 return false;
522 }
523
525 if (!promise_ref.active_delay_context.compare_exchange_strong(
527 std::memory_order_acq_rel, std::memory_order_acquire)) {
528 return false;
529 }
530
531 promise_ref.sample_satisfied.store(false, std::memory_order_release);
532 promise_ref.frame_satisfied.store(false, std::memory_order_release);
533
535 return true;
536}
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)