algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::runner::ClockReference< Clock > Class Template Reference

A clock that reads another one, so that two holders (a loop and its journal) read one time. More...

#include <algotradelib/src/runner/clock.hpp>

Public Member Functions

 ClockReference (Clock &clock) noexcept
 Refers to a clock.
std::chrono::system_clock::time_point now () const
 Returns the referenced clock's wall-clock time.
std::chrono::steady_clock::time_point monotonic_now () const
 Returns the referenced clock's monotonic reading.
void wait_for (std::chrono::nanoseconds duration)
 Waits on the referenced clock.

Detailed Description

template<typename Clock>
class algotradelib::runner::ClockReference< Clock >

A clock that reads another one, so that two holders (a loop and its journal) read one time.

Clocks are taken by value, and a copy of a ManualClock does not follow the original: a journal given one copy and a loop given another would stamp lines at the starting time while the loop moves on. Give both a ClockReference to the same clock instead.

Template Parameters
ClockThe clock read; it must outlive every copy of the reference.

Definition at line 60 of file clock.hpp.

Constructor & Destructor Documentation

◆ ClockReference()

template<typename Clock>
algotradelib::runner::ClockReference< Clock >::ClockReference ( Clock & clock)
inlineexplicitnoexcept

Refers to a clock.

Parameters
clockThe clock; borrowed, and must outlive every copy of this reference.

Definition at line 66 of file clock.hpp.

Member Function Documentation

◆ monotonic_now()

template<typename Clock>
std::chrono::steady_clock::time_point algotradelib::runner::ClockReference< Clock >::monotonic_now ( ) const
inline

Returns the referenced clock's monotonic reading.

Returns
Its monotonic_now().

Definition at line 78 of file clock.hpp.

◆ now()

template<typename Clock>
std::chrono::system_clock::time_point algotradelib::runner::ClockReference< Clock >::now ( ) const
inline

Returns the referenced clock's wall-clock time.

Returns
Its now().

Definition at line 72 of file clock.hpp.

◆ wait_for()

template<typename Clock>
void algotradelib::runner::ClockReference< Clock >::wait_for ( std::chrono::nanoseconds duration)
inline

Waits on the referenced clock.

Parameters
durationHow long.

Definition at line 84 of file clock.hpp.


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