Module Make.Clock
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val default_timing_wheel_config : Core_kernel.Timing_wheel_ns.Config.tThe default timing-wheel configuration, with one millisecond precision with alarms up to 30 days in the future.
val create : ?timing_wheel_config:Core_kernel.Timing_wheel_ns.Config.t -> start:Incremental__.Import.Time_ns.t -> unit -> tval alarm_precision : t -> Incremental__.Import.Time_ns.Span.tThe
alarm_precisionof the underlying timing wheel.
val timing_wheel_length : t -> intval now : t -> Incremental__.Import.Time_ns.tnow treturns the current time of incremental's clock.
val watch_now : t -> Incremental__.Import.Time_ns.t incrementalwatch_now treturns an incremental that tracks the current time.
val advance_clock : t -> to_:Incremental__.Import.Time_ns.t -> unitadvance_clock t ~to_moves incremental's clock forward toto_.advance_clockraises ifto_ < now t. As withVar.set, the effect ofadvance_clockis not seen on incremental values until the next stabilization. UnlikeVar.set, callingadvance_clockduring stabilization raises.In certain pathological cases,
advance_clockcan raise due to it detecting a cycle in the incremental graph.
val at : t -> Incremental__.Import.Time_ns.t -> Before_or_after.t incrementalat timereturns an incremental that isBeforewhennow () <= timeandAfterwhennow () >= time + alarm_precision. Whennow ()is betweentimeandtime + alarm_precision,at timemight beBeforeorAfter, due to the fundamental imprecision of the timing wheel. One is guaranteed that anatnever becomesAftertoo early, but it may becomeAfterup toalarm_precisionlate.after spanisat (Time_ns.add (now ()) span).
val after : t -> Incremental__.Import.Time_ns.Span.t -> Before_or_after.t incrementalval at_intervals : t -> Incremental__.Import.Time_ns.Span.t -> unit incrementalat_intervals intervalreturns an incremental whose value changes at time intervals of the form:Time_ns.next_multiple ~base ~after ~intervalwhere
baseisnow ()whenat_intervalswas called andafteris the currentnow (). As withat,at_intervalsmight fire up toalarm_precisionlate.at_intervalsraises ifinterval < alarm_precision. Theunit tthatat_intervalsreturns has its cutoff set toCutoff.never, so that although its value is always(), incrementals that depend on it will refire each time it is set. The result ofat_intervalsremains 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 -> (Incremental__.Import.Time_ns.t * 'a) list -> 'a incrementalstep_function ~init [(t1, v1); ...; (tn, vn)]returns an incremental whose initial value isinitand takes on the valuesv1, ...,vnin sequence taking on the valueviwhen the clock's time passesti. As withat, the steps might take effect up toalarm_precisionlate.It is possible for
vito be skipped if time advances fromt(i-1)to some time greater thant(i+1).The times must be in nondecreasing order, i.e.
step_functionraises if for somei < j,ti > tj.
val snapshot : t -> 'a incremental -> at:Incremental__.Import.Time_ns.t -> before:'a -> 'a incremental Core_kernel.Or_error.tsnapshot value_at ~at ~beforereturns an incremental whose value isbeforebeforeatand whose value is frozen to the value ofvalue_atduring the first stabilization after which the time passesat.snapshotcausesvalue_atto be necessary during the first stabilization after which time passesateven if thesnapshotnode itself is not necessary, but not thereafter (although of coursevalue_atcould remain necessary for other reaspons). The result ofsnapshotwill only be invalidated ifvalue_atis invalid at the moment of the snapshot.snapshotreturnsErrorifat < now (), because it is impossible to take the snapshot because the time has already passed.