|
HikoGUI
A low latency retained GUI
|
#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. | |
The maintence thread.
This thread will execute callbacks at given intervals.
| using tt::timer::callback_type = std::function<void(time_point,bool)> |
Timer callback.
| current_time | The current time of executing this timer. |
| last | True if this is the last time this timer is called, on emergency stop. |
|
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.
| interval | The interval to execute the callback at. |
|
noexcept |
Remove the callback function.
|
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.
|
noexcept |
Stop the timer thread.
Maybe called to emergency stop the timer thread, this will cause all callbacks to be called with last=true.