module Make_poweroff_resistant:
Given a watcher w
:
Tick.LIFECYCLE.suspend
event while
Tick.WATCHER.waiting
w
is true
, the value of
Tick.WATCHER.linger_ns
w
is an accurate and exact wall-clock time
span.Tick.LIFECYCLE.suspend
and
Tick.LIFECYCLE.resume
events while Tick.WATCHER.waiting
w
is true
and that the difference between the value of Tick.PCLOCK.now_d_ps
at these events provides an accurate measure of the actual wall-clock
time span that elapsed during suspension, the value of
Tick.WATCHER.linger_ns
w
is an accurate and exact wall-clock time
span.
This condition is typically satisfied if Tick.PCLOCK
is well synchronized
at Tick.LIFECYCLE.suspend
and Tick.LIFECYCLE.resume
and no leap second
occurs between these two events. The absolute value of Tick.PCLOCK
doesn't
matter.
Tick.LIFECYCLE.poweroff
and
Tick.LIFECYCLE.poweron
events and that the difference between
the value of Tick.PCLOCK.now_d_ps
at these events provides an accurate
measure of the actual wall-clock time span that elapsed during the
poweroff, the value of Tick.WATCHER.linger_ns
w
is an accurate and
exact wall-clock time span.
This condition is typically satisfied if Tick.PCLOCK
is well synchronized
at Tick.LIFECYCLE.poweroff
and Tick.LIFECYCLE.poweron
and no leap second
occurs between these two events. The absolute value of Tick.PCLOCK
doesn't
matter.
Tick.PERSISTENT_TRIGGER
interface.Parameters: |
|
typespan_ns =
int64
type
trigger
type
t
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
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:
linger_ns w < delay_ns w
the tick was in advance.linger_ns w = delay_ns w
the tick was on time.linger_ns w > delay_ns w
the tick was late.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