senf::ClockService Class Reference

Reliable high precision monotonous clock source. More...

#include <senf/Scheduler/ClockService.hh>

Inheritance diagram for senf::ClockService:
Inheritance graph
[legend]

List of all members.


Detailed Description

Reliable high precision monotonous clock source.

The ClockService provides a highly accurate monotonous clock source based on gettimeofday(). However, it takes additional precautions to detect clock skew.

Implementation note:
The funny mixture of static and non-static members stems from the old implementation based on interval timers and gettimeofday(). The current implementation uses POSIX clocks and is much simpler and more precise.

Definition at line 64 of file ClockService.hh.


Public Types

typedef config::time_type  clock_type
  ClockService timer data type.
typedef boost::int_fast64_t  int64_type
  Supplementary integer type.
typedef boost::posix_time::ptime  abstime_type
  Absolute time data type.
typedef
boost::posix_time::time_duration 
reltime_type
  Relative time data type.

Static Public Member Functions

static clock_type  now ()
  Return current clock value.
static abstime_type  abstime (clock_type clock)
  Convert clock to absolute time.
static reltime_type  reltime (clock_type clock)
  Convert clock to relative time.
static clock_type  clock (abstime_type time)
  Convert absolute time to clock value.
static clock_type  from_time_t (time_t const &time)
  Convert legacy time_t to clock value.
static clock_type  from_timeval (timeval const &time)
  Convert legacy timeval to clock value.
static clock_type  nanoseconds (int64_type v)
  Convert v nanoseconds to clock_type.
static clock_type  microseconds (int64_type v)
  Convert v microseconds to clock_type.
static clock_type  milliseconds (int64_type v)
  Convert v milliseconds to clock_type.
static clock_type  seconds (int64_type v)
  Convert v seconds to clock_type.
static clock_type  minutes (int64_type v)
  Convert v minutes to clock_type.
static clock_type  hours (int64_type v)
  Convert v hours to clock_type.
static clock_type  days (int64_type v)
  Convert v days to clock_type.
static int64_type  in_nanoseconds (clock_type v)
  Convert v to nanoseconds.
static int64_type  in_microseconds (clock_type v)
  Convert v to microseconds.
static int64_type  in_milliseconds (clock_type v)
  Convert v to milliseconds.
static int64_type  in_seconds (clock_type v)
  Convert v to seconds.
static int64_type  in_minutes (clock_type v)
  Convert v to minutes.
static int64_type  in_hours (clock_type v)
  Convert v to hours.
static int64_type  in_days (clock_type v)
  Convert v to days.
static void  restart ()
  Force re-synchronization of abstime and clock.

Member Typedef Documentation

typedef boost::posix_time::ptime senf::ClockService::
abstime_type

Absolute time data type.

Boost.DateTime datatype used to represent absolute date/time values.

Definition at line 89 of file ClockService.hh.

typedef config::time_type senf::ClockService::
clock_type

ClockService timer data type.

Unsigned integer type representing scheduler time. Scheduler time is measured in nanoseconds relative to some implementation defined reference time.

Definition at line 76 of file ClockService.hh.

typedef boost::int_fast64_t senf::ClockService::
int64_type

Supplementary integer type.

This type is used to represent varies supplementary values (e.g. number of microseconds)

Definition at line 82 of file ClockService.hh.

typedef boost::posix_time::time_duration senf::ClockService::
reltime_type

Relative time data type.

Boost.DateTime datatype used to represent time intervals

Definition at line 96 of file ClockService.hh.


Member Function Documentation

senf::ClockService::abstime_type senf::ClockService::
abstime ( clock_type  clock )

Convert clock to absolute time.

This member converts a clock value into an absolute Boost.DateTime value.

Note:
You should not base timeout calculations on this absolute time value. Clock time is guaranteed to be monotonous, absolute time may be non-monotonous if the system date/time is changed.

Definition at line 85 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
clock ( abstime_type  time )

Convert absolute time to clock value.

This member convert an absolute time value into the corresponding clock value.

See also:
abstime

Definition at line 99 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
days ( int64_type  v )

Convert v days to clock_type.

Definition at line 139 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
from_time_t ( time_t const &  time )

Convert legacy time_t to clock value.

This member converts an absolute time value represented as a time_t value into a clock value

Definition at line 104 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
from_timeval ( timeval const &  time )

Convert legacy timeval to clock value.

This member converts an absolute time value represented as a timeval value into a clock value

Definition at line 179 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
hours ( int64_type  v )

Convert v hours to clock_type.

Definition at line 134 of file ClockService.cci.

static int64_type senf::ClockService::
in_days ( clock_type  v )

Convert v to days.

static int64_type senf::ClockService::
in_hours ( clock_type  v )

Convert v to hours.

static int64_type senf::ClockService::
in_microseconds ( clock_type  v )

Convert v to microseconds.

static int64_type senf::ClockService::
in_milliseconds ( clock_type  v )

Convert v to milliseconds.

static int64_type senf::ClockService::
in_minutes ( clock_type  v )

Convert v to minutes.

static int64_type senf::ClockService::
in_nanoseconds ( clock_type  v )

Convert v to nanoseconds.

static int64_type senf::ClockService::
in_seconds ( clock_type  v )

Convert v to seconds.

senf::ClockService::clock_type senf::ClockService::
microseconds ( int64_type  v )

Convert v microseconds to clock_type.

Definition at line 114 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
milliseconds ( int64_type  v )

Convert v milliseconds to clock_type.

Definition at line 119 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
minutes ( int64_type  v )

Convert v minutes to clock_type.

Definition at line 129 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
nanoseconds ( int64_type  v )

Convert v nanoseconds to clock_type.

Definition at line 109 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
now ()

Return current clock value.

Definition at line 37 of file ClockService.cci.

senf::ClockService::reltime_type senf::ClockService::
reltime ( clock_type  clock )

Convert clock to relative time.

This member converts a clock value into a relative Boost.DateTime time interval

Note:
The resolution of reltime_type might be smaller than the clock_type resolution

Definition at line 90 of file ClockService.cci.

void senf::ClockService::
restart ()

Force re-synchronization of abstime and clock.

Calling the member should never be necessary since abstime() / clock() automatically call restart() if needed

Definition at line 184 of file ClockService.cci.

senf::ClockService::clock_type senf::ClockService::
seconds ( int64_type  v )

Convert v seconds to clock_type.

Definition at line 124 of file ClockService.cci.


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