Attempts to resume the coroutine with explicit temporal context.
- Parameters
-
| current_value | Current position in the timeline (samples, frames, cycles, etc.) |
| context | The temporal context being processed |
- Returns
- True if the coroutine was resumed, false otherwise
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.
The default implementation delegates to try_resume(uint64_t) for backward compatibility. Derived classes can override to implement context-specific resumption logic.
Reimplemented from MayaFlux::Vruta::Routine.
Definition at line 98 of file Routine.cpp.
99{
101 return false;
102
103 auto& promise_ref =
m_handle.promise();
104
105 if (promise_ref.should_terminate || !promise_ref.auto_resume) {
106 return false;
107 }
108
111 }
112
113 if (promise_ref.active_delay_context !=
DelayContext::NONE && promise_ref.active_delay_context != context) {
114 return false;
115 }
116
117 bool should_resume = false;
118
119 switch (context) {
122 should_resume = (current_value >= promise_ref.next_sample);
123 if (should_resume) {
124 promise_ref.next_sample = current_value + promise_ref.delay_amount;
125 }
126 } else {
127 should_resume = false;
128 }
129 break;
130
133 should_resume = (current_value >= promise_ref.next_buffer_cycle);
134 } else {
135 should_resume = false;
136 }
137 break;
138
140 should_resume = true;
141 break;
142
143 default:
144 return false;
145 }
146
147 if (should_resume) {
149 return true;
150 }
151
152 return false;
153}
std::coroutine_handle< promise_type > m_handle
Handle to the underlying coroutine.
bool is_active() const override
Checks if the coroutine is still active.
bool initialize_state(uint64_t current_sample=0U) override
Initializes the coroutine's state for execution.
@ NONE
No active delay, try resume immediately.
@ SAMPLE_BASED
Sample-accurate delay (audio domain)
@ BUFFER_BASED
Buffer-cycle delay (audio hardware boundary)
@ AWAIT
Awaiter-induced delay (temporary suspension)
References MayaFlux::Vruta::AWAIT, MayaFlux::Vruta::BUFFER_BASED, initialize_state(), is_active(), m_handle, MayaFlux::Vruta::NONE, and MayaFlux::Vruta::SAMPLE_BASED.
Referenced by try_resume().