libqi-api  2.4.3.28
 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. More...

#include <clock.hpp>

Public Types

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

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.

Definition at line 76 of file clock.hpp.

Member Typedef Documentation

typedef boost::chrono::duration<rep, period> qi::Clock::duration

The duration type of the clock.

Definition at line 81 of file clock.hpp.

typedef boost::nano qi::Clock::period

The tick period of the clock in nanoseconds.

Definition at line 80 of file clock.hpp.

The representation type of the duration and time_point.

Definition at line 79 of file clock.hpp.

typedef boost::chrono::time_point<Clock> qi::Clock::time_point

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 87 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 97 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 93 of file clock.hpp.


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