Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
kvikio::ClockAnchor Struct Reference

A reading of Clock and of the wall clock, taken together. More...

#include <observation.hpp>

Public Member Functions

std::chrono::system_clock::time_point to_wall_clock (TimePoint time) const noexcept
 Convert a point on Clock to wall-clock time. More...
 

Static Public Member Functions

static ClockAnchor now () noexcept
 Read both clocks, one immediately after the other. More...
 

Public Attributes

TimePoint steady {}
 The reading of Clock.
 
std::chrono::system_clock::time_point wall {}
 The reading of the wall clock, taken at the same moment.
 

Detailed Description

A reading of Clock and of the wall clock, taken together.

Clock cannot be compared with anything outside this process, so an anchor is what relates an observation to a log line, to another process, or to a profiler trace.

Definition at line 39 of file observation.hpp.

Member Function Documentation

◆ now()

static ClockAnchor kvikio::ClockAnchor::now ( )
staticnoexcept

Read both clocks, one immediately after the other.

Warning
The readings are tens of nanoseconds apart, since the two clocks cannot be read at once, so the anchor's offset is out by that much. Well below what a wall clock is worth anyway, NTP agreeing between machines to microseconds at best.
Returns
The pair of readings.

◆ to_wall_clock()

std::chrono::system_clock::time_point kvikio::ClockAnchor::to_wall_clock ( TimePoint  time) const
inlinenoexcept

Convert a point on Clock to wall-clock time.

Warning
The wall clock can be stepped or slewed by NTP or an operator, so an old anchor may no longer be valid. Take an anchor at each end of a long run and compare them to detect an in-flight adjustment to the system time.
Parameters
timeThe point to convert.
Returns
The corresponding wall-clock time.

Definition at line 66 of file observation.hpp.


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