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

Utility for executing actions with a start and end function over a duration. More...

#include <Timers.hpp>

+ Collaboration diagram for MayaFlux::Kriya::TimedAction:

Public Member Functions

 TimedAction (Vruta::TaskScheduler &scheduler)
 Constructs a TimedAction with the specified scheduler.
 
 ~TimedAction ()=default
 
void execute (std::function< void()> start_func, std::function< void()> end_func, double duration_seconds)
 Executes a pair of functions with a time interval between them.
 
void cancel ()
 Cancels any active action.
 
bool is_pending () const
 Checks if an action is currently in progress.
 

Private Attributes

Vruta::TaskSchedulerm_Scheduler
 Reference to the scheduler that manages this action.
 
Timer m_timer
 The timer used to schedule the end function.
 

Detailed Description

Utility for executing actions with a start and end function over a duration.

The TimedAction class provides a way to execute a pair of functions with a specified time interval between them. This is useful for operations that need to start and then automatically stop after a duration, such as activating a process, applying a transformation, or implementing any time-bounded state change.

Example usage:

// Create a timed action
TimedAction action(*scheduler);
// Execute an action that lasts for 3 seconds
action.execute(
[]() { std::cout << "Starting action" << std::endl; },
[]() { std::cout << "Ending action" << std::endl; },
3.0
);
Utility for executing actions with a start and end function over a duration.
Definition Timers.hpp:142

Only one action can be active at a time; executing a new action cancels any previously active action.

Definition at line 142 of file Timers.hpp.


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