klee
klee::Timer Class Reference

#include <Timer.h>

Collaboration diagram for klee::Timer:

Public Member Functions

 Timer (const time::Span &interval, std::function< void()> &&callback)
 
time::Span getInterval () const
 Return specified interval between invocations. More...
 
void invoke (const time::Point &currentTime)
 Execute callback if invocation time exceeded. More...
 
void reset (const time::Point &currentTime)
 Set new invocation time to currentTime + interval. More...
 

Private Attributes

time::Span interval
 Approximate interval between callback invocations. More...
 
time::Point nextInvocationTime
 Wall time for next invocation. More...
 
std::function< void()> run
 The event callback. More...
 

Detailed Description

A Timer repeatedly executes a callback after a specified interval. An object of this class is passive and only keeps track of the next invocation time. Passive means, that it has to be invoked by an external caller with the current time. Only when the time span between the current time and the last invocation exceeds the specified interval, the callback will be executed. Multiple timers are typically managed by a TimerGroup.

Definition at line 43 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( const time::Span interval,
std::function< void()> &&  callback 
)
Parameters
intervalThe time span between callback invocations.
callbackThe event callback.

Definition at line 29 of file Timer.cpp.

Member Function Documentation

◆ getInterval()

time::Span Timer::getInterval ( ) const

Return specified interval between invocations.

Definition at line 32 of file Timer.cpp.

References interval.

Referenced by klee::TimerGroup::add().

Here is the caller graph for this function:

◆ invoke()

void Timer::invoke ( const time::Point currentTime)

Execute callback if invocation time exceeded.

Definition at line 36 of file Timer.cpp.

References interval, nextInvocationTime, and run.

Referenced by klee::TimerGroup::invoke().

Here is the caller graph for this function:

◆ reset()

void Timer::reset ( const time::Point currentTime)

Set new invocation time to currentTime + interval.

Definition at line 43 of file Timer.cpp.

References interval, and nextInvocationTime.

Referenced by klee::TimerGroup::reset().

Here is the caller graph for this function:

Member Data Documentation

◆ interval

time::Span klee::Timer::interval
private

Approximate interval between callback invocations.

Definition at line 45 of file Timer.h.

Referenced by getInterval(), invoke(), and reset().

◆ nextInvocationTime

time::Point klee::Timer::nextInvocationTime
private

Wall time for next invocation.

Definition at line 47 of file Timer.h.

Referenced by invoke(), and reset().

◆ run

std::function<void()> klee::Timer::run
private

The event callback.

Definition at line 49 of file Timer.h.

Referenced by invoke().


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