CARMA C++
PeriodicTimer.h
1 #ifndef CARMA_UTIL_PERIODIC_TIMER_H
2 #define CARMA_UTIL_PERIODIC_TIMER_H
3 
4 #include <ctime>
5 
6 #include <sys/time.h>
7 
8 #include "carma/util/ScheduledTimer.h"
9 
10 namespace carma {
11 namespace util {
12 
22 
23 class PeriodicTimer : public ScheduledTimer {
24  public:
25 
43 
44  explicit PeriodicTimer( const struct ::timespec & period,
45  bool preflight = true );
46 
47 
51 
52  explicit PeriodicTimer( const struct ::timeval & period,
53  bool preflight = true );
54 
55 
62 
63  void ResetNextFireAbsoluteTime( const struct ::timespec & nextFireAbsoluteTime );
64 
65 
69 
70  void ResetNextFireAbsoluteTime( const struct ::timeval & nextFireAbsoluteTime );
71 
72 
80 
81  void ResetNextFireAbsoluteTimeAndWait( const struct ::timespec & nextFireAbsoluteTime );
82 
83 
87 
88  void ResetNextFireAbsoluteTimeAndWait( const struct ::timeval & nextFireAbsoluteTime );
89 
90  protected:
91  virtual struct ::timespec CalculateNextFireAbsoluteTime( const struct ::timespec & fireAbsoluteTime );
92 
93  private:
94  const struct ::timespec period_;
95 };
96 
97 } // namespace util
98 } // namespace carma
99 
100 #endif
PeriodicTimer(const struct::timespec &period, bool preflight=true)
Construct an instance with the given period.
Abstract base class for PthreadCond::TimedWait based timers.
void ResetNextFireAbsoluteTimeAndWait(const struct::timespec &nextFireAbsoluteTime)
Same as ResetNextFireAbsoluteTime( const struct ::timespec &amp; ) except that this method also waits for...
Timer object that fires at a fixed rate.
Definition: PeriodicTimer.h:23
void ResetNextFireAbsoluteTime(const struct::timespec &nextFireAbsoluteTime)
Reset the next fire time (and by association the entire queue of fire times) for this instance...