BlueZero (BØ)
Middleware for distributed applications
time_sync.h
1 #ifndef B0__UTILS__TIMESYNC_H__INCLUDED
2 #define B0__UTILS__TIMESYNC_H__INCLUDED
3 
4 #include <cstdint>
5 
6 #include <boost/thread/mutex.hpp>
7 
52 namespace b0
53 {
54 
60 class TimeSync
61 {
62 public:
67  TimeSync(double max_slope = 0.5);
68 
72  virtual ~TimeSync();
73 
77  virtual int64_t hardwareTimeUSec() const;
78 
82  virtual int64_t timeUSec();
83 
88  virtual int64_t constantRateAdjustedOffset();
89 
93  virtual void updateTime(int64_t remoteTime);
94 
95 private:
96  /*
97  * State variables related to time synchronization
98  */
99  int64_t target_offset_;
100  int64_t max_acceptable_offset_;
101  int64_t last_offset_time_;
102  int64_t last_offset_value_;
103  double max_slope_;
104  boost::mutex mutex_;
105 };
106 
107 } // namespace b0
108 
109 #endif // B0__UTILS__TIMESYNC_H__INCLUDED
virtual int64_t hardwareTimeUSec() const
Return this computer&#39;s clock time in microseconds.
virtual void updateTime(int64_t remoteTime)
virtual ~TimeSync()
TimeSync destructor.
virtual int64_t constantRateAdjustedOffset()
The TimeSync class.
Definition: time_sync.h:60
TimeSync(double max_slope=0.5)
TimeSync constructor.
Definition: node.h:17
virtual int64_t timeUSec()
Return the adjusted time in microseconds. See Time Synchronization for details.