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

#include <hikogui/function_timer.hpp>

Public Types

using function_type = std::function<Proto>
 
using token_type = std::shared_ptr<function_type>
 
using weak_token_type = std::weak_ptr<function_type>
 
using result_type = hi_typename function_type::result_type
 

Public Member Functions

constexpr bool empty () const noexcept
 
std::pair< token_type, bool > delay_function (utc_nanoseconds time_point, auto &&func) noexcept
 Add a function to be called at a certain time.
 
std::pair< token_type, bool > repeat_function (std::chrono::nanoseconds period, utc_nanoseconds time_point, auto &&func) noexcept
 Add a function to be called repeatedly.
 
std::pair< token_type, bool > repeat_function (std::chrono::nanoseconds period, auto &&func) 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 &&...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< token_type, bool > v1::function_timer< Proto >::delay_function ( utc_nanoseconds time_point,
auto && func )
inlinenoexcept

Add a function to be called at a certain time.

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

◆ repeat_function() [1/2]

template<typename Proto = void()>
std::pair< token_type, bool > v1::function_timer< Proto >::repeat_function ( std::chrono::nanoseconds period,
auto && func )
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.
funcThe function to be called.
Returns
token, next to call.

◆ repeat_function() [2/2]

template<typename Proto = void()>
std::pair< token_type, bool > v1::function_timer< Proto >::repeat_function ( std::chrono::nanoseconds period,
utc_nanoseconds time_point,
auto && func )
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.
funcThe 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 &&... 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: