Class Timer

Class Documentation

class Timer

Simple periodic timer that spawns a thread to call a function at specified interval.

Public Functions

Timer() = delete
Timer(std::function<void(void)> func, std::chrono::milliseconds interval)

Does not start the timer.

Parameters:
  • func – Callback to call periodically

  • interval – How often to call func

virtual ~Timer()
void start()

Create background thread and start timer No-op if already running.

void stop()

Interrupt and destroy background thread. Can be restarted with start() No-op if not running.

bool isRunning()

If timer has been started.