The real clock a live loop uses: wall-clock time to stamp events, monotonic time to wait and to measure how long something took.
More...
#include <algotradelib/src/runner/clock.hpp>
|
| std::chrono::system_clock::time_point | now () const noexcept |
| | Returns the current wall-clock time.
|
| std::chrono::steady_clock::time_point | monotonic_now () const noexcept |
| | Returns a reading that only moves forward, for measuring elapsed time.
|
| void | wait_for (std::chrono::nanoseconds duration) const |
| | Blocks for a duration, measured on the monotonic clock.
|
The real clock a live loop uses: wall-clock time to stamp events, monotonic time to wait and to measure how long something took.
now() is wall-clock time (it can jump when NTP or an operator sets the clock), because events are stamped with it and must agree with brokers' timestamps. wait_for() is measured on steady_clock, so a sleep is as long as it was asked to be whatever happens to the wall clock, and monotonic_now() reads that clock, which is what a bounded wait is measured on (PollingLoop::set_closing_wait). When a poll is next due is still a wall-clock time. A custom clock for a loop needs the same three calls; ManualClock is the test version.
Definition at line 20 of file clock.hpp.
◆ monotonic_now()
| std::chrono::steady_clock::time_point algotradelib::runner::SteadyClock::monotonic_now |
( |
| ) |
const |
|
inlinenoexcept |
Returns a reading that only moves forward, for measuring elapsed time.
- Returns
- std::chrono::steady_clock::now().
Definition at line 34 of file clock.hpp.
◆ now()
| std::chrono::system_clock::time_point algotradelib::runner::SteadyClock::now |
( |
| ) |
const |
|
inlinenoexcept |
Returns the current wall-clock time.
- Returns
- std::chrono::system_clock::now().
Definition at line 26 of file clock.hpp.
◆ wait_for()
| void algotradelib::runner::SteadyClock::wait_for |
( |
std::chrono::nanoseconds | duration | ) |
const |
|
inline |
Blocks for a duration, measured on the monotonic clock.
- Parameters
-
| duration | How long to wait; zero or negative returns at once. |
Definition at line 42 of file clock.hpp.
The documentation for this class was generated from the following file: