libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Static Public Member Functions | Public Attributes | List of all members
qi::Clock Class Reference

The Clock class represents a system-wide clock, best suitable for timestamping events. Typically monotonic and unaffected by the system clock adjustment, altough this is not guaranteed. More...

#include <clock.hpp>

Public Types

enum  Expect { Expect_SoonerOrLater, Expect_Later, Expect_Sooner }
 Enum expected argument. More...
 
using rep = Duration::rep
 The representation type of the duration and time_point. More...
 
using period = Duration::period
 The tick period of the clock in nanoseconds. More...
 
using duration = Duration
 The duration type of the clock. More...
 
using time_point = boost::chrono::time_point< Clock >
 

Static Public Member Functions

static time_point now ()
 Returns a time_point representing the current value of the clock. More...
 
static uint32_t toUint32ms (const time_point &t) throw ()
 Convert the time point to a number of milliseconds on 32 bits. More...
 
static int32_t toInt32ms (const time_point &t) throw ()
 Convert the time point to a number of milliseconds on 32 bits. More...
 
static time_point fromUint32ms (uint32_t t_ms, time_point guess, Expect expect=Expect_SoonerOrLater) throw ()
 Get a time point from a number of milliseconds on 32 bits. More...
 
static time_point fromInt32ms (int32_t t_ms, time_point guess, Expect expect=Expect_SoonerOrLater) throw ()
 Get a time point from a number of milliseconds on 32 bits. More...
 

Public Attributes

bool is_steady = boost::chrono::steady_clock::is_steady
 

Detailed Description

The Clock class represents a system-wide clock, best suitable for timestamping events. Typically monotonic and unaffected by the system clock adjustment, altough this is not guaranteed.

Definition at line 85 of file clock.hpp.

Member Typedef Documentation

The duration type of the clock.

Definition at line 90 of file clock.hpp.

using qi::Clock::period = Duration::period

The tick period of the clock in nanoseconds.

Definition at line 89 of file clock.hpp.

using qi::Clock::rep = Duration::rep

The representation type of the duration and time_point.

Definition at line 88 of file clock.hpp.

using qi::Clock::time_point = boost::chrono::time_point<Clock>

The time_point type of the clock. Different clocks are permitted to share a time_point definition if it is valid to compare their time_points by comparing their respective durations.

Definition at line 96 of file clock.hpp.

Member Enumeration Documentation

Enum expected argument.

Enumerator
Expect_SoonerOrLater 

Pick the nearest result to user-provided reference.

Expect_Later 

Result is expected to be later than user-provided reference.

Expect_Sooner 

Result is expected to be sooner than user-provided reference.

Definition at line 106 of file clock.hpp.

Member Function Documentation

static time_point qi::Clock::fromInt32ms ( int32_t  t_ms,
time_point  guess,
Expect  expect = Expect_SoonerOrLater 
)
throw (
)
static

Get a time point from a number of milliseconds on 32 bits.

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 + period
  • if expect == SOONER, result is expected to be sooner than guess: guess - period < result <= guess
  • if expect == SOONER_OR_LATER, pick the nearest result: guess - period/2 < result <= guess + period/2

where period == 2^32 ms ~ 50 days

static time_point qi::Clock::fromUint32ms ( uint32_t  t_ms,
time_point  guess,
Expect  expect = Expect_SoonerOrLater 
)
throw (
)
static

Get a time point from a number of milliseconds on 32 bits.

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 + period
  • if expect == SOONER, result is expected to be sooner than guess: guess - period < result <= guess
  • if expect == SOONER_OR_LATER, pick the nearest result: guess - period/2 < result <= guess + period/2

where period == 2^32 ms ~ 50 days

static time_point qi::Clock::now ( )
static

Returns a time_point representing the current value of the clock.

static int32_t qi::Clock::toInt32ms ( const time_point t)
throw (
)
static

Convert the time point to a number of milliseconds on 32 bits.

Since the 32 bits number overflows every 2^32 ms ~ 50 days, this is a lossy operation.

Parameters
tThe time point to convert.
Returns
Integer (int) representing the time.
static uint32_t qi::Clock::toUint32ms ( const time_point t)
throw (
)
static

Convert the time point to a number of milliseconds on 32 bits.

Since the 32 bits number overflows every 2^32 ms ~ 50 days, this is a lossy operation.

Parameters
tThe time point to convert.
Returns
Unsigned int representing the time.

Member Data Documentation

bool qi::Clock::is_steady = boost::chrono::steady_clock::is_steady

true if t1 <= t2 is always true, else false.

Note
A clock that can be adjusted backwards is not steady.

Definition at line 102 of file clock.hpp.


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