Module type Tick.WATCHER

module type WATCHER = sig .. end
The type for clock tick watchers.

WATCHER provides a base signature for watching nanosecond precision clock ticks.



Tick watchers


type span_ns = int64 
The type for positive nanoseconds time spans. This is an unsigned 64-bit integer it can represent time spans up to approximatevley 584 Julian years.
type trigger 
The type for tick watcher triggers. This is the value being acted upon when a watcher sees a tick.
type t 
The type for tick watchers. Encapsulate a delay to watch for and a trigger to actuate whenever the delay elapsed.
val watch : delay_ns:span_ns -> trigger -> t
watch d tr is a tick in that occurs after d nanoseconds and is watched by trigger tr.
val unwatch : t -> unit
unwatch w unwatches the tick in w. If w is no longer Tick.WATCHER.waiting this has no effect. Otherwise w's trigger is guaranteed not to be actuated and Tick.WATCHER.waiting w becomes false.
val waiting : t -> bool
waiting w is true iff w's trigger has not been actuated yet or w was not Tick.WATCHER.unwatched.
val linger_ns : t -> span_ns
linger_ns w is the number of nanoseconds during which Tick.WATCHER.waiting w was true. If w's trigger was actuated then:
val delay_ns : t -> span_ns
delay_ns w is w's waiting delay.
val trigger : t -> trigger
trigger w is w's trigger.
val fold : ('a -> t -> 'a) -> 'a -> 'a
fold f acc folds over all watchers that have Tick.WATCHER.waiting t = true.