qi clocks

Libqi provides types to model clocks, time points and durations.
The implementation is based on boost::chrono.
You can thus refer to
boost::chrono documentation
or to
your favourite C++11 book for a detailed description.
Here is a short introduction to the concepts though.

libqi exposes several clocks, each of which having a distinctive set of
properties.

Possible properties are:

monotonicity

A clock is monotonic if the time points of this clock cannot decrease
as physical time moves forward.

steadiness

A clock is steady if the physical time between its ticks is constant.
This property implies monotonicity.

system-wideness

A clock C may be system-wide. In such a case, all programs on the system
calling C::now() at the same time should get the same value.

relation to “real time wall clock”

A clock may represent “real wall clock” time. In such a case its time
points are convertible to calendar time. Such a clock is usually not steady
nor monotonic in order to enable the adjustment of the clock.

monotonic and steady clock, but
not
system-wide.
Its epoch is unspecified, but typically related only to the program
invocation (eg. the program starting time).
Similar to std::chrono::steady_clock.
This clock is best suitable for measuring intervals.

system-wide real time wall clock.
Similar to std::chrono::system_clock.
This clock is best used when calendar time is needed.
It may also be useful in specific cases for inter-system communication,
assuming the systems involved do synchronize their system clocks.

Since the 32 bits number overflows every ~50 days, an infinity of time points match a given 32 bits number (all modulo ~50 days). This function picks the result near the guess timepoint depending on the expect argument:

if expect == LATER, result is expected to be later than guess: guess <= result < guess + periodif expect == SOONER, result is expected to be sooner than guess: guess - period < result <= guessif expect == SOONER_OR_LATER, pick the nearest result: guess - period/2 < result <= guess + period/2

Since the 32 bits number overflows every ~50 days, an infinity of time points match a given 32 bits number (all modulo ~50 days). This function picks the result near the guess timepoint depending on the expect argument:

if expect == LATER, result is expected to be later than guess: guess <= result < guess + periodif expect == SOONER, result is expected to be sooner than guess: guess - period < result <= guessif expect == SOONER_OR_LATER, pick the nearest result: guess - period/2 < result <= guess + period/2