Motion Master
|
Listener for periodic ticks from a MainTimer. More...
#include <main_timer_listener.h>
Public Member Functions | |
MainTimerListener () | |
Constructs a new MainTimerListener instance. More... | |
void | wait () |
Waits for the next timer tick and updates internal state. More... | |
uint64_t | getTickCount () const |
Returns the number of ticks since the first tick received. More... | |
uint64_t | getCycleCount () const |
Returns the number of completed wait cycles. More... | |
int64_t | getElapsedTime () const |
Returns the total elapsed time since the listener was created. More... | |
Listener for periodic ticks from a MainTimer.
The MainTimerListener class allows a thread to wait for periodic ticks generated by a MainTimer instance. It tracks tick counts, completed wait cycles, and elapsed time since its creation. This is useful for applications that require precise, per-thread timing synchronization based on a shared timer.
MainTimerListener::MainTimerListener | ( | ) |
Constructs a new MainTimerListener instance.
Initializes counters for ticks, reference tick, and cycles. Also records the start time using the system's high-resolution clock.
uint64_t MainTimerListener::getCycleCount | ( | ) | const |
Returns the number of completed wait cycles.
Each call to wait()
increases the cycle count. This provides a measure of how many complete wait-tick sequences have occurred.
int64_t MainTimerListener::getElapsedTime | ( | ) | const |
Returns the total elapsed time since the listener was created.
Calculates the elapsed time in microseconds using a high-resolution clock.
uint64_t MainTimerListener::getTickCount | ( | ) | const |
Returns the number of ticks since the first tick received.
The tick count is adjusted to be relative to the first tick seen by this listener instance.
void MainTimerListener::wait | ( | ) |
Waits for the next timer tick and updates internal state.
Blocks the current thread until a tick is received from the MainTimer. Increments tick and cycle counters. Each successful call represents a completed timing cycle.