MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kriya::Timer Class Reference

High-level utility for scheduling one-shot timed callbacks. More...

#include <Timers.hpp>

+ Collaboration diagram for MayaFlux::Kriya::Timer:

Public Member Functions

 Timer (Vruta::TaskScheduler &scheduler)
 Constructs a Timer with the specified scheduler.
 
 ~Timer ()=default
 
void schedule (double delay_seconds, std::function< void()> callback)
 Schedules a callback to execute after a delay.
 
void cancel ()
 Cancels any scheduled callback.
 
bool is_active () const
 Checks if a callback is currently scheduled.
 

Private Attributes

Vruta::TaskSchedulerm_Scheduler
 Reference to the scheduler that manages this timer.
 
std::shared_ptr< Vruta::SoundRoutinem_routine
 The underlying computational routine that implements the timer.
 
bool m_active
 Flag indicating whether a callback is currently scheduled.
 
std::function< void()> m_callback
 The callback function to execute when the timer fires.
 

Detailed Description

High-level utility for scheduling one-shot timed callbacks.

The Timer class provides a convenient way to schedule a function to execute after a specified delay. It wraps the lower-level computational routine system in a simple interface that's easier to use for common timing scenarios.

Unlike traditional timers which can drift due to system load, Timer uses the engine's sample-accurate clock to ensure precise, deterministic timing that's perfectly synchronized with the processing pipeline.

Example usage:

// Create a timer
Timer timer(*scheduler);
// Schedule a callback to execute after 2 seconds
timer.schedule(2.0, []() {
std::cout << "Two seconds have passed!" << std::endl;
});
High-level utility for scheduling one-shot timed callbacks.
Definition Timers.hpp:38

Only one callback can be scheduled at a time; scheduling a new callback cancels any previously scheduled callback.

Definition at line 38 of file Timers.hpp.


The documentation for this class was generated from the following files: