xronos-sdk 0.2.0
Xronos C++ SDK
 
Loading...
Searching...
No Matches
xronos::sdk::PeriodicTimer Class Referencefinal

A trigger that emits events in regular intervals. More...

#include <xronos/sdk/periodic_timer.hh>

Inheritance diagram for xronos::sdk::PeriodicTimer:
[legend]

Public Member Functions

 PeriodicTimer (std::string_view name, ReactorContext context, Duration period, Duration offset=Duration::zero())
 Construct a new PeriodicTimer object.
 
auto period () const noexcept -> const Duration &
 The delay in between two events emitted by the timer.
 
auto offset () const noexcept -> const Duration &
 The delay between Reactor::startup and the first event emitted by the timer.
 
- Public Member Functions inherited from xronos::sdk::Element
auto name () const noexcept -> const std::string &
 The name of the current element.
 
auto fqn () const noexcept -> const std::string &
 The fully qualified name of the current element.
 
- Public Member Functions inherited from xronos::sdk::EventSource< void >
virtual ~EventSource ()=default
 Correct deletion of an instance of a derived class is permitted.
 
virtual ~EventSource ()=default
 Correct deletion of an instance of a derived class is permitted.
 

Detailed Description

A trigger that emits events in regular intervals.

Constructor & Destructor Documentation

◆ PeriodicTimer()

xronos::sdk::PeriodicTimer::PeriodicTimer ( std::string_view name,
ReactorContext context,
Duration period,
Duration offset = Duration::zero() )

Construct a new PeriodicTimer object.

Parameters
nameThe name of the timer event.
contextThe current reactor's initialization context, which can be obtained using the Reactor::context method.
periodThe delay in between two events emitted by the timer. See Timer::period for details.
offsetThe delay between Reactor::startup and the first event emitted by the timer.

Member Function Documentation

◆ period()

auto xronos::sdk::PeriodicTimer::period ( ) const -> const Duration &
nodiscardnoexcept

The delay in between two events emitted by the timer.

If period is 0 (the default), then the timer will trigger only once with a delay of offset after Reactor::startup triggers. If offset is also set to 0, the timer triggers simultaneously to Reactor::startup.

Returns
const Duration& The delay in between two events emitted by the timer.

◆ offset()

auto xronos::sdk::PeriodicTimer::offset ( ) const -> const Duration &
nodiscardnoexcept

The delay between Reactor::startup and the first event emitted by the timer.

Returns
const Duration& The delay between Reactor::startup and the first event emitted by the timer.

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