CrossGuard
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Timer Class Reference

Timer class for asynchronous execution after a specified delay. More...

#include <Timer.h>

Public Member Functions

 Timer ()
 Default constructor. Initializes the timer in a stopped state.
 
template<typename Function >
void setTimeout (Function function, int delayMs)
 Starts a timer to execute a function after a specified delay.
 
void stopTimer ()
 Stops any ongoing timer and prevents the scheduled function from executing.
 

Detailed Description

Timer class for asynchronous execution after a specified delay.

The Timer class allows scheduling a function to be executed after a specified delay. It provides functionality to stop the timer, preventing the execution of the function if needed.

Member Function Documentation

◆ setTimeout()

template<typename Function >
void Timer::setTimeout ( Function function,
int delayMs )
inline

Starts a timer to execute a function after a specified delay.

If there is an ongoing timer, it is stopped before starting the new one.

Template Parameters
FunctionType of the function to be executed.
Parameters
functionFunction to be executed after the delay.
delayMsDelay in milliseconds before the function is executed.

◆ stopTimer()

void Timer::stopTimer ( )
inline

Stops any ongoing timer and prevents the scheduled function from executing.

If the timer is already stopped or the function has already executed, this method does nothing.


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