Motion Master
Loading...
Searching...
No Matches
Public Member Functions | List of all members
MainTimerListener Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MainTimerListener()

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.

Member Function Documentation

◆ getCycleCount()

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.

Returns
Completed cycle count as an unsigned 64-bit integer.

◆ getElapsedTime()

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.

Returns
Elapsed time in microseconds as a signed 64-bit integer.

◆ getTickCount()

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.

Returns
Relative tick count as an unsigned 64-bit integer.

◆ wait()

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.


The documentation for this class was generated from the following files: