40 explicit CyclicTimer(std::chrono::microseconds period);
91 void setPeriod(std::chrono::microseconds period);
95 void* handle_ =
nullptr;
97 int64_t periodTicks_ = 0;
106 void advanceOnePeriod() {
107 next_nsec_ += period_ns_;
108 if (next_nsec_ >= 1'000'000'000L) {
109 next_nsec_ -= 1'000'000'000L;
114 int64_t period_ns_ = 0;
115 int64_t next_sec_ = 0;
116 int64_t next_nsec_ = 0;
Precision cyclic timer for fixed-period loops.
Definition cyclic_timer.h:35
CyclicTimer & operator=(const CyclicTimer &)=delete
Copy assignment is deleted — see copy constructor.
CyclicTimer(const CyclicTimer &)=delete
Copying is deleted — each instance owns its own deadline state and, on Windows, an OS timer handle th...
~CyclicTimer()
Destroys the timer. On Windows, cancels and closes the OS timer handle. On Linux, no OS resource is h...
Definition cyclic_timer_windows.cc:36
void setPeriod(std::chrono::microseconds period)
Changes the cycle period and re-anchors the deadline grid to now.
Definition cyclic_timer_linux.cc:16
uint64_t waitForNextCycle()
Blocks until the next cycle deadline, then returns.
Definition cyclic_timer_linux.cc:24
Definition cyclic_timer.h:6