From: g0dil Date: Fri, 21 Nov 2008 16:57:18 +0000 (+0000) Subject: Scheduler/ClockService: Add reltime() and reltime_type X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=5b2dbbd878b2d947c25e9affe015197b0ef1c813;p=senf.git Scheduler/ClockService: Add reltime() and reltime_type git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@971 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Scheduler/ClockService.cci b/Scheduler/ClockService.cci index 3c15955..791a403 100644 --- a/Scheduler/ClockService.cci +++ b/Scheduler/ClockService.cci @@ -83,6 +83,15 @@ prefix_ senf::ClockService::abstime_type senf::ClockService::abstime(clock_type return instance().abstime_m(clock); } +prefix_ senf::ClockService::reltime_type senf::ClockService::reltime(clock_type clock) +{ +#ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + return boost::posix_time::nanoseconds(clock); +#else + return boost::posix_time::microseconds((clock+500)/1000); +#endif +} + prefix_ senf::ClockService::clock_type senf::ClockService::clock(abstime_type time) { return instance().clock_m(time); diff --git a/Scheduler/ClockService.hh b/Scheduler/ClockService.hh index 02082ea..6067cec 100644 --- a/Scheduler/ClockService.hh +++ b/Scheduler/ClockService.hh @@ -86,6 +86,12 @@ namespace senf { */ typedef boost::posix_time::ptime abstime_type; + /** \brief Relative time data type + + Boost.DateTime datatype used to represent time intervals + */ + typedef boost::posix_time::time_duration reltime_type; + /////////////////////////////////////////////////////////////////////////// static clock_type now(); ///< Return current clock value @@ -98,6 +104,12 @@ namespace senf { monotonous, absolute time may be non-monotonous if the system date/time is changed. */ + static reltime_type 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 */ + static clock_type clock(abstime_type time); ///< Convert absolute time to clock value /**< This member converst an absolute time value into the corresponding clock value.