MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ try_resume_with_context()

bool MayaFlux::Vruta::GraphicsRoutine::try_resume_with_context ( uint64_t  current_value,
DelayContext   
)
overridevirtual

Attempts to resume the coroutine with explicit temporal context.

Parameters
current_valueCurrent position in the timeline (samples, frames, cycles, etc.)
contextThe 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 298 of file Routine.cpp.

299{
300 if (!is_active())
301 return false;
302
303 auto& promise_ref = m_handle.promise();
304
305 if (promise_ref.should_terminate || !promise_ref.auto_resume) {
306 return false;
307 }
308
309 if (context != DelayContext::NONE && promise_ref.active_delay_context == DelayContext::AWAIT) {
310 return initialize_state(current_value);
311 }
312
313 if (promise_ref.active_delay_context != DelayContext::NONE && promise_ref.active_delay_context != context) {
314 return false;
315 }
316
317 bool should_resume = false;
318
319 switch (context) {
321 if (promise_ref.active_delay_context == DelayContext::FRAME_BASED) {
322 should_resume = (current_value >= promise_ref.next_frame);
323 if (should_resume) {
324 promise_ref.next_frame = current_value + promise_ref.delay_amount;
325 }
326 } else {
327 should_resume = false;
328 }
329 break;
330
332 should_resume = true;
333 break;
334
335 default:
336 return false;
337 }
338
339 if (should_resume) {
340 m_handle.resume();
341 return true;
342 }
343
344 return false;
345}
bool initialize_state(uint64_t current_frame=0U) override
Initializes the coroutine's state for execution.
Definition Routine.cpp:274
bool is_active() const override
Checks if the coroutine is still active.
Definition Routine.cpp:269
std::coroutine_handle< promise_type > m_handle
Handle to the underlying coroutine.
Definition Routine.hpp:654
@ FRAME_BASED
Frame-rate delay (Graphics domain)
@ NONE
No active delay, resume immediately.
@ AWAIT
Awaiter-induced delay (temporary suspension)

References MayaFlux::Vruta::AWAIT, MayaFlux::Vruta::FRAME_BASED, initialize_state(), is_active(), m_handle, and MayaFlux::Vruta::NONE.

Referenced by try_resume().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: