Motion Master
Loading...
Searching...
No Matches
main_timer_listener.h
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <chrono>
5#include <mutex>
6
18 public:
26
34 void wait();
35
44 uint64_t getTickCount() const;
45
54 uint64_t getCycleCount() const;
55
63 int64_t getElapsedTime() const;
64
65 private:
67 std::mutex mx_;
68
70 std::atomic<uint64_t> tickCount_;
71
73 std::atomic<uint64_t> refTickCount_;
74
76 std::atomic<uint64_t> cycleCount_;
77
79 int64_t start_;
80};
Listener for periodic ticks from a MainTimer.
Definition: main_timer_listener.h:17
uint64_t getCycleCount() const
Returns the number of completed wait cycles.
Definition: main_timer_listener.cc:37
MainTimerListener()
Constructs a new MainTimerListener instance.
Definition: main_timer_listener.cc:5
uint64_t getTickCount() const
Returns the number of ticks since the first tick received.
Definition: main_timer_listener.cc:35
int64_t getElapsedTime() const
Returns the total elapsed time since the listener was created.
Definition: main_timer_listener.cc:39
void wait()
Waits for the next timer tick and updates internal state.
Definition: main_timer_listener.cc:13