From 9705e16ca6d0b4c9e75266d2174d15f0d25b2606 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franc=CC=A7ois=20Pottier?= <francois.pottier@inria.fr>
Date: Tue, 11 Mar 2025 22:33:01 +0100
Subject: [PATCH] Clock: internal change: replace [second] field with [last]
 field.

---
 src/Clock.ml | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/Clock.ml b/src/Clock.ml
index dfa2b22..6a417fc 100644
--- a/src/Clock.ml
+++ b/src/Clock.ml
@@ -22,8 +22,8 @@ type clock = {
   mutable now: float;
   (* The number of ticks that have taken place. *)
   mutable ticks: int;
-  (* The elapsed time, in integer seconds. *)
-  mutable second: int;
+  (* The last time [tick] was called for this clock. *)
+  mutable last: float;
   (* A circular array of the times at which the most recent round ticks
      took place. *)
   window: float array;
@@ -39,7 +39,7 @@ let make granularity =
     start;
     now = start;
     ticks = 0;
-    second = 0;
+    last = 0.;
     window = Array.make n start;
     next = 0;
   } in
@@ -55,11 +55,10 @@ let tick clock f =
     clock.window.(clock.next) <- clock.now;
     let n = Array.length clock.window in
     clock.next <- (clock.next + 1) mod n;
-    let second' = truncate (clock.now -. clock.start) in
     (* Check if roughly one new second has elapsed. If so, call the user
        function [f]. *)
-    if second' > clock.second then begin
-      clock.second <- second';
+    if clock.now > clock.last +. 1. then begin
+      clock.last <- clock.now;
       f()
     end
   end
-- 
GitLab