HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
tt::timer Class Reference

#include <TTauri/Foundation/timer.hpp>

Public Types

using duration = hires_utc_clock::duration
 
using time_point = hires_utc_clock::time_point
 
using callback_type = std::function<void(time_point,bool)>
 Timer callback.
 

Public Member Functions

 timer (std::string name) noexcept
 
void start () noexcept
 Start the timer thread.
 
void stop () noexcept
 Stop the timer thread.
 
size_t add_callback (duration interval, callback_type callback) noexcept
 Add a callback function to be executed each interval.
 
void remove_callback (size_t callback_id) noexcept
 Remove the callback function.
 

Detailed Description

The maintence thread.

This thread will execute callbacks at given intervals.

Member Typedef Documentation

◆ callback_type

Timer callback.

Parameters
current_timeThe current time of executing this timer.
lastTrue if this is the last time this timer is called, on emergency stop.

Member Function Documentation

◆ add_callback()

size_t tt::timer::add_callback ( duration interval,
callback_type callback )
noexcept

Add a callback function to be executed each interval.

The callback will be executed at each interval when: cpu_utc_clock::now() % interval == 0

Since there is only a single thread, please make sure the callback executes quickly.

Parameters
intervalThe interval to execute the callback at.
Returns
An identifier for the callback to be able to remove it.

◆ remove_callback()

void tt::timer::remove_callback ( size_t callback_id)
noexcept

Remove the callback function.

◆ start()

void tt::timer::start ( )
noexcept

Start the timer thread.

Normally it is not needed to call this yourself. If there are no callbacks registered the thread will exit itself.

◆ stop()

void tt::timer::stop ( )
noexcept

Stop the timer thread.

Maybe called to emergency stop the timer thread, this will cause all callbacks to be called with last=true.


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