package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou-core.interfaces/Miaou_interfaces/Clock/index.html
Module Miaou_interfaces.ClockSource
Clock capability — provides elapsed time since the last tick.
Drivers register this capability before entering the main loop. The driver updates the internal state at the start of every tick so that pages and widgets can query timing information without calling Unix.gettimeofday themselves.
Usage in pages / widgets:
let clock = Clock.require () in
let dt = clock.dt () in
(* dt is the seconds elapsed since the previous tick *)Usage in drivers:
let clock_state = Clock.create_state () in
Clock.register clock_state ;
(* At the top of every tick: *)
Clock.tick clock_state ;Mutable driver-side state. Drivers create one of these, register it, and call tick at the start of every tick iteration.
type t = {dt : unit -> float;(*Seconds elapsed since the previous tick. Returns
*)0.on the first tick.now : unit -> float;(*Wall-clock time at the start of the current tick (equivalent to
*)Unix.gettimeofday ()but cached — zero-cost to call multiple times within the same tick).elapsed : unit -> float;(*Seconds elapsed since the clock was created (i.e. since the driver started the main loop).
*)
}The read-only view exposed to pages and widgets via the capability registry.
Capability access
Driver-side API
Create a new clock state, recording the current wall-clock time as the origin.