X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FClockService.hh;h=3d5f40f554ba3e2cf0d8a8f27fb8d01663fcf3fd;hb=3d16600678b948ff3bd0e4fd2a1a800fcc629a03;hp=6ad51b5be9ca7395b3e2365bd1ae42c072fe1479;hpb=77a726fdfa20680c691ba528fdad979422ef829c;p=senf.git diff --git a/Scheduler/ClockService.hh b/Scheduler/ClockService.hh index 6ad51b5..3d5f40f 100644 --- a/Scheduler/ClockService.hh +++ b/Scheduler/ClockService.hh @@ -28,13 +28,18 @@ // Custom includes #include -#include +#include +#include //#include "ClockService.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { +#ifndef DOXYGEN + namespace detail { class ClockServiceTest; } +#endif + // Implementation note: // // The clock value is represented as a 64bit unsigned integer number of nanosecods elapsed since @@ -72,8 +77,6 @@ namespace senf { The ClockService provides a highly accurate monotonous clock source based on gettimeofday(). However, it takes additional precautions to detect clock skew. - - \fixme Implement the clock-skew detection */ class ClockService : boost::noncopyable @@ -121,14 +124,40 @@ namespace senf { corresponding clock value. \see abstime */ + static clock_type nanoseconds(clock_type v); + static clock_type microseconds(clock_type v); + static clock_type milliseconds(clock_type v); + static clock_type seconds(clock_type v); + static clock_type minutes(clock_type v); + static clock_type hours(clock_type v); + static clock_type days(clock_type v); + + static void restart(); + protected: private: + ClockService(); static ClockService & instance(); + clock_type now_i(); + void restart_i(); + + bool checkSkew(boost::posix_time::ptime time); + void clockSkew(boost::posix_time::ptime time, boost::posix_time::ptime expected); + void updateSkew(boost::posix_time::ptime time); boost::posix_time::ptime base_; + boost::posix_time::ptime heartbeat_; + + struct Impl; + boost::scoped_ptr impl_; + + friend class Impl; +#ifndef DOXYGEN + friend class senf::detail::ClockServiceTest; +#endif };