HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
v1::function_timer< Proto > Class Template Reference

#include <hikogui/dispatch/function_timer.hpp>

Public Types

using callback_proto = Proto
 
using function_type = std::function<callback_proto>
 
using callback_token = std::shared_ptr<function_type>
 
using weak_callback_token = std::weak_ptr<function_type>
 
using result_type = function_type::result_type
 

Public Member Functions

constexpr bool empty () const noexcept
 
std::pair< callback_token, bool > delay_function (utc_nanoseconds time_point, forward_of< callback_proto > auto &&callback) noexcept
 Add a function to be called at a certain time.
 
std::pair< callback_token, bool > repeat_function (std::chrono::nanoseconds period, utc_nanoseconds time_point, forward_of< callback_proto > auto &&callback) noexcept
 Add a function to be called repeatedly.
 
std::pair< callback_token, bool > repeat_function (std::chrono::nanoseconds period, forward_of< callback_proto > auto &&callback) noexcept
 Add a function to be called repeatedly.
 
utc_nanoseconds current_deadline () const noexcept
 Get the deadline of the next function to call.
 
void run_all (utc_nanoseconds current_time, auto const &...args) noexcept
 Run all the function that should have run by the current_time.
 

Detailed Description

template<typename Proto = void()>
class v1::function_timer< Proto >

A time that calls functions.

Template Parameters
Protothe prototype of the function passed.
Sizethe size of the function object.

Member Function Documentation

◆ current_deadline()

template<typename Proto = void()>
utc_nanoseconds v1::function_timer< Proto >::current_deadline ( ) const
inlinenoexcept

Get the deadline of the next function to call.

Returns
The deadline of the next function to call, or far/max into the future.

◆ delay_function()

template<typename Proto = void()>
std::pair< callback_token, bool > v1::function_timer< Proto >::delay_function ( utc_nanoseconds time_point,
forward_of< callback_proto > auto && callback )
inlinenoexcept

Add a function to be called at a certain time.

Parameters
time_pointThe time when to call the function.
callbackThe function to be called.
Returns
token, next to call.

◆ repeat_function() [1/2]

template<typename Proto = void()>
std::pair< callback_token, bool > v1::function_timer< Proto >::repeat_function ( std::chrono::nanoseconds period,
forward_of< callback_proto > auto && callback )
inlinenoexcept

Add a function to be called repeatedly.

Parameters
periodThe period between repeated calls
callbackThe function to be called.
Returns
token, next to call.

◆ repeat_function() [2/2]

template<typename Proto = void()>
std::pair< callback_token, bool > v1::function_timer< Proto >::repeat_function ( std::chrono::nanoseconds period,
utc_nanoseconds time_point,
forward_of< callback_proto > auto && callback )
inlinenoexcept

Add a function to be called repeatedly.

Parameters
periodThe period between repeated calls
time_pointThe time when to call the function the first time.
callbackThe function to be called.
Returns
token, next to call.

◆ run_all()

template<typename Proto = void()>
void v1::function_timer< Proto >::run_all ( utc_nanoseconds current_time,
auto const &... args )
inlinenoexcept

Run all the function that should have run by the current_time.

Parameters
current_timeThe current time.
argsThe arguments to pass to the function.

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