This commit is contained in:
Simon Cruanes 2026-01-12 20:59:05 -05:00
parent 696a5d4b91
commit 610244aad4
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -21,6 +21,7 @@ end
(** Clock that uses ptime. *) (** Clock that uses ptime. *)
let ptime_clock : t = { now = now_ptime_ } let ptime_clock : t = { now = now_ptime_ }
(** Singleton clock *)
module Main = struct module Main = struct
open struct open struct
let main : t Atomic.t = Atomic.make ptime_clock let main : t Atomic.t = Atomic.make ptime_clock
@ -28,9 +29,12 @@ module Main = struct
let[@inline] get () = Atomic.get main let[@inline] get () = Atomic.get main
(** Set the current clock *)
let set t : unit = Util_atomic.update_cas main (fun _ -> (), t) let set t : unit = Util_atomic.update_cas main (fun _ -> (), t)
(** Clock that always defers to the current main clock *) (** Clock that always defers to the current main clock. Whenever
[now dynamic_main] is called, it in turn becomes [now (get ())], ie it
looks up the current clock and uses it. *)
let dynamic_main : t = { now = (fun () -> now (get ())) } let dynamic_main : t = { now = (fun () -> now (get ())) }
end end