Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val default_timing_wheel_config : Timing_wheel.Config.t
The default timing-wheel configuration, with one millisecond precision, and alarms allowed arbitrarily far in the future.
val create :
?timing_wheel_config:Timing_wheel.Config.t ->
start:Core_kernel.Int63.t ->
unit ->
t
val alarm_precision : t -> Core_kernel.Time_ns.Span.t
The alarm_precision
of the underlying timing wheel.
val timing_wheel_length : t -> int
val now : t -> Core_kernel.Int63.t
now t
returns the current time of incremental's clock.
val watch_now : t -> Core_kernel.Int63.t incremental
watch_now t
returns an incremental that tracks the current time.
val advance_clock : t -> to_:Core_kernel.Int63.t -> unit
advance_clock t ~to_
moves incremental's clock forward to to_
. advance_clock
is a no-op if to_ < now t
. As with Var.set
, the effect of advance_clock
is not seen on incremental values until the next stabilization. Unlike Var.set
, calling advance_clock
during stabilization raises.
In certain pathological cases, advance_clock
can raise due to it detecting a cycle in the incremental graph.
val advance_clock_by : t -> Core_kernel.Time_ns.Span.t -> unit
advance_clock_by t span = advance_clock t ~to_:(Time_ns.add (now t) span)
val at : t -> Core_kernel.Int63.t -> Before_or_after.t incremental
at t time
returns an incremental that is Before
when now t < time
and After
when now t >= time
.
val after : t -> Core_kernel.Time_ns.Span.t -> Before_or_after.t incremental
after t span
is at t (Time_ns.add (now t) span)
.
val at_intervals : t -> Core_kernel.Time_ns.Span.t -> unit incremental
at_intervals t interval
returns an incremental whose value changes at time intervals of the form:
Time_ns.next_multiple ~base ~after ~interval
where base
is now t
when at_intervals
was called and after
is the current now t
.
at_intervals
raises if interval < alarm_precision
. The unit t
that at_intervals
returns has its cutoff set to Cutoff.never
, so that although its value is always ()
, incrementals that depend on it will refire each time it is set. The result of at_intervals
remains alive and is updated until the left-hand side of its defining bind changes, at which point it becomes invalid.
val step_function :
t ->
init:'a ->
(Core_kernel.Int63.t * 'a) list ->
'a incremental
step_function t ~init [(t1, v1); ...; (tn, vn)]
returns an incremental whose initial value is init
and takes on the values v1
, ..., vn
in sequence taking on the value vi
when now t >= ti
.
It is possible for vi
to be skipped if time advances from t(i-1)
to some time greater than t(i+1)
.
The times must be in nondecreasing order, i.e. step_function
raises if for some i < j
, ti > tj
.
val incremental_step_function :
t ->
'a Step_function.t incremental ->
'a incremental
incremental_step_function t i
returns an incremental whose value is Step_function.value f ~at:(now t)
, where f
is the value of i
.
val snapshot :
t ->
'a incremental ->
at:Core_kernel.Int63.t ->
before:'a ->
'a incremental Core_kernel.Or_error.t
snapshot t value_at ~at ~before
returns an incremental whose value is before
before at
and whose value is frozen to the value of value_at
during the first stabilization in which the time passes at
. snapshot
causes value_at
to be necessary during that stabilization even if the snapshot
node itself is not necessary, but not thereafter (although of course value_at
could remain necessary for other reaspons). The result of snapshot
will only be invalidated if value_at
is invalid at the moment of the snapshot.
snapshot
returns Error
if at < now t
, because it is impossible to take the snapshot because the time has already passed.