From e97bd18127fe019dd14256d807f9ea5d06cc36b1 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 5 Apr 2026 14:47:39 -0700 Subject: Add timer_advance for virtual simulation --- timer/include/timer.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'timer/include') diff --git a/timer/include/timer.h b/timer/include/timer.h index 6dc87d9..75ae367 100644 --- a/timer/include/timer.h +++ b/timer/include/timer.h @@ -21,10 +21,10 @@ typedef uint64_t time_delta; /// A high resolution timer. typedef struct Timer { - time_point start_time; // The instant the timer was last started. - time_point last_tick; // The instant the timer was last ticked. - time_delta running_time; // Time elapsed since the timer was last started. - time_delta delta_time; // Time elapsed since the last tick. + time_point start_time; ///< The instant the timer was last started. + time_point last_tick; ///< The instant the timer was last ticked. + time_delta running_time; ///< Time elapsed since the timer was last started. + time_delta delta_time; ///< Time elapsed since the last tick. } Timer; /// Construct a new timer. @@ -38,6 +38,15 @@ void timer_start(Timer*); /// Update the timer's running and delta times. void timer_tick(Timer*); +/// Advance the timer. +/// +/// This is used for simulations that wish control over time. It should not be +/// used together with timer_tick(). +/// +/// The input time is relative to the timer's start time. Successive calls to +/// this function must use increasing values of time. +void timer_advance(Timer* timer, time_delta t); + /// Get the current time. time_point time_now(void); -- cgit v1.2.3