17 #ifndef HH_SENF_Scheduler_ClockService_ 18 #define HH_SENF_Scheduler_ClockService_ 1 21 #include <boost/date_time/posix_time/posix_time.hpp> 22 #include <senf/config.hh> 31 # define SENF_CLOCKSERVICE_CONSTEXPR 33 # ifdef SENF_CXX11_ENABLED 34 # define SENF_CLOCKSERVICE_CONSTEXPR constexpr 36 # define SENF_CLOCKSERVICE_CONSTEXPR 75 struct ClockTypeTag {};
102 static constexpr clock_type
maxTime = std::numeric_limits<config::time_type>::max();
104 static clock_type
now();
122 static clock_type
clock(abstime_type
const & time);
127 static clock_type
from_time_t(time_t
const & time);
132 static time_t
to_time_t(clock_type
const & time);
166 abstime_type abstime_m(clock_type
const &
clock);
167 clock_type clock_m(abstime_type
const & time);
170 boost::posix_time::ptime baseAbstime_;
171 clock_type baseClock_;
228 void update(std::uint32_t
const & secs, std::uint32_t
const & nsecs) {
229 tstamp_ = (secs * 1000) + (nsecs / 1000000);
232 std::uint32_t
const &
value()
const {
241 return other.tstamp_ - tstamp_;
253 std::uint32_t tstamp_;
config::time_type clock_type
ClockService timer data type.
static clock_type from_time_t(time_t const &time)
Convert legacy time_t to clock value.
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_milliseconds(clock_type const &v)
Convert v to milliseconds.
static SENF_CLOCKSERVICE_CONSTEXPR clock_type days(int64_type const &v)
Convert v days to clock_type.
boost::posix_time::time_duration reltime_type
Relative time data type.
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_hours(clock_type const &v)
Convert v to hours.
static SENF_CLOCKSERVICE_CONSTEXPR clock_type hours(int64_type const &v)
Convert v hours to clock_type.
static SENF_CLOCKSERVICE_CONSTEXPR clock_type seconds(int64_type const &v)
Convert v seconds to clock_type.
CyclicTimestamp(std::uint32_t const &secs, std::uint32_t const &nsecs)
Reliable high precision monotonous clock source.
std::uint32_t const & value() const
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_microseconds(clock_type const &v)
Convert v to microseconds.
static constexpr clock_type maxTime
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_days(clock_type const &v)
Convert v to days.
static time_t to_time_t(clock_type const &time)
Convert legacy time_t to clock value to legacy time_t.
static SENF_CLOCKSERVICE_CONSTEXPR clock_type milliseconds(int64_type const &v)
Convert v milliseconds to clock_type.
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_nanoseconds(clock_type const &v)
Convert v to nanoseconds.
static reltime_type reltime(clock_type const &clock)
Convert clock to relative time.
void update(std::uint32_t const &secs, std::uint32_t const &nsecs)
senf::ClockService::clock_type distanceAsClockType(CyclicTimestamp const &other) const
static SENF_CLOCKSERVICE_CONSTEXPR clock_type microseconds(int64_type const &v)
Convert v microseconds to clock_type.
void formatClockServiceInterval(ClockService::clock_type interval, std::ostream &os)
#define SENF_CLOCKSERVICE_CONSTEXPR
static abstime_type abstime(clock_type const &clock)
Convert clock to absolute time.
static void restart()
Force re-synchronization of abstime and clock.
std::int64_t int64_type
Supplementary integer type.
boost::iterator_range< token_iterator > TokensRange
boost::posix_time::ptime abstime_type
Absolute time data type.
void parseClockServiceInterval(console::ParseCommandInfo::TokensRange const &tokens, ClockService::clock_type &out)
Console argument parser to parse value as time interval.
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_minutes(clock_type const &v)
Convert v to minutes.
static clock_type now()
Return current clock value.
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_seconds(clock_type const &v)
Convert v to seconds.
std::uint32_t distanceAsMilliseconds(CyclicTimestamp const &other) const
void update(ClockService::clock_type const &clockType)
static clock_type from_timeval(timeval const &time)
Convert legacy timeval to clock value.
static SENF_CLOCKSERVICE_CONSTEXPR clock_type minutes(int64_type const &v)
Convert v minutes to clock_type.
CyclicTimestamp distance(CyclicTimestamp const &other) const
static clock_type clock(abstime_type const &time)
Convert absolute time to clock value.
static SENF_CLOCKSERVICE_CONSTEXPR clock_type nanoseconds(int64_type const &v)
Convert v nanoseconds to clock_type.