Module Core_kernel.Timing_wheel_ns
module Time : Timing_wheel_ns_intf.Timing_wheel_time with type t = Time_ns.t and type Span.t = Time_ns.Span.tmodule Alarm_precision : Timing_wheel_ns_intf.Alarm_precision with module Time := Timeval sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
type 'a timing_wheel= 'a ttype 'a t_now= 'a t<:sexp_of< _ t_now >>displays onlynow t, not all the alarms.
val sexp_of_t_now : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t_now -> Ppx_sexp_conv_lib.Sexp.t
module Alarm : sig ... endinclude Core_kernel__.Import.Invariant.S1 with type 'a t := 'a t
val invariant : 'a Base__.Invariant_intf.inv -> 'a t Base__.Invariant_intf.inv
module Level_bits : sig ... endmodule Config : sig ... endval create : config:Config.t -> start:Time.t -> 'a tcreate ~config ~startcreates a new timing wheel with current timestart.createraises ifstart < Time.epoch. For a fixedlevel_bits, a smaller (i.e. more precise)alarm_precisiondecreases the representable range of times/keys and increases the constant factor foradvance_clock.
val alarm_precision : _ t -> Time.Span.tAccessors
val is_empty : _ t -> Core_kernel__.Import.boolval length : _ t -> Core_kernel__.Import.intval iter : 'a t -> f:('a Alarm.t -> Core_kernel__.Import.unit) -> Core_kernel__.Import.unitval interval_num : _ t -> Time.t -> Interval_num.tinterval_num t timereturns the number of the interval thattimeis in, where0is the interval that starts atTime.epoch.interval_numraises ifTime.( < ) time Time.epoch.now_interval_num tequalsinterval_num t (now t).
val now_interval_num : _ t -> Interval_num.tval interval_num_start : _ t -> Interval_num.t -> Time.tinterval_num_start t nis the start of then'th interval int, i.e.n * alarm_precision tafter the epoch.interval_start t timeis the start of the half-open interval containingtime, i.e.:interval_num_start t (interval_num t time)interval_startraises in the same cases thatinterval_numdoes.
val interval_start : _ t -> Time.t -> Time.tval advance_clock : 'a t -> to_:Time.t -> handle_fired:('a Alarm.t -> Core_kernel__.Import.unit) -> Core_kernel__.Import.unitadvance_clock t ~to_ ~handle_firedadvancest's clock toto_. It fires and removes all alarmsaintwithTime.(<) (Alarm.at t a) (interval_start t to_), applyinghandle_firedto each sucha.If
to_ <= now t, thenadvance_clockdoes nothing.advance_clockfails ifto_is too far in the future to represent.Behavior is unspecified if
handle_firedaccessestin any way other thanAlarmfunctions.
val fire_past_alarms : 'a t -> handle_fired:('a Alarm.t -> Core_kernel__.Import.unit) -> Core_kernel__.Import.unitfire_past_alarms t ~handle_firedfires and removes all alarmsaintwithTime.( <= ) (Alarm.at t a) (now t), applyinghandle_firedto each sucha.fire_past_alarmsvisits all alarms in intervalnow_interval_num, to check theirAlarm.at.Behavior is unspecified if
handle_firedaccessestin any way other thanAlarmfunctions.
val alarm_upper_bound : _ t -> Time.talarm_upper_bound treturns the upper bound on anatthat can be supplied toadd.alarm_upper_bound tis not constant; its value increases asnow tincreases.
val max_allowed_alarm_time : _ t -> Time.tmax_allowed_alarm_time treturns the greatestatthat can be supplied toadd.max_allowed_alarm_timeis not constant; its value increases asnow tincreases.
val min_allowed_alarm_interval_num : _ t -> Interval_num.tmin_allowed_alarm_interval_num t = now_interval_num t
val max_allowed_alarm_interval_num : _ t -> Interval_num.tmax_allowed_alarm_interval_num t = interval_num t (max_allowed_alarm_time t)
val add : 'a t -> at:Time.t -> 'a -> 'a Alarm.tadd t ~at aadds a new valueatotand returns an alarm that can later be supplied toremovethe alarm fromt.addraises ifinterval_num t at < now_interval_num t || at > max_allowed_alarm_time t.add_at_interval_num t ~at ais equivalent toadd t ~at:(interval_num_start t at) a.
val add_at_interval_num : 'a t -> at:Interval_num.t -> 'a -> 'a Alarm.tval mem : 'a t -> 'a Alarm.t -> Core_kernel__.Import.boolval remove : 'a t -> 'a Alarm.t -> Core_kernel__.Import.unitremove t alarmremovesalarmfromt.removeraises ifnot (mem t alarm).
val reschedule : 'a t -> 'a Alarm.t -> at:Time.t -> Core_kernel__.Import.unitreschedule t alarm ~atmutatesalarmso that it will fire atat, i.e. so thatAlarm.at t alarm = at.rescheduleraises ifnot (mem t alarm)or ifatis an invalid time fort, in the same situations thataddraises.reschedule_at_interval_num t alarm ~atis equivalent to:reschedule t alarm ~at:(interval_num_start t at)
val reschedule_at_interval_num : 'a t -> 'a Alarm.t -> at:Interval_num.t -> Core_kernel__.Import.unitval clear : _ t -> Core_kernel__.Import.unitclear tremoves all alarms fromt.
val min_alarm_interval_num : _ t -> Interval_num.t Core_kernel__.Import.optionmin_alarm_interval_num tis the minimumAlarm.interval_numof all alarms int.min_alarm_interval_num_exn tis the same, except it raises ifis_empty t.
val min_alarm_interval_num_exn : _ t -> Interval_num.tval max_alarm_time_in_min_interval : 'a t -> Time.t Core_kernel__.Import.optionmax_alarm_time_in_min_interval treturns the maximumAlarm.atover all alarms intwhoseAlarm.interval_numismin_alarm_interval_num t.max_alarm_time_in_min_interval_exn tis the same asmax_alarm_time_in_min_interval, except that it raises ifis_empty t.This function is useful for advancing to the
min_alarm_interval_numof a timing wheel and then callingfire_past_alarmsto fire the alarms in that interval. That is useful when simulating time, to ensure that alarms are processed in order.
val max_alarm_time_in_min_interval_exn : 'a t -> Time.tval next_alarm_fires_at : _ t -> Time.t Core_kernel__.Import.optionnext_alarm_fires_at treturns the minimum time to which the clock can be advanced such that an alarm will fire, orNoneifthas no alarms. Ifnext_alarm_fires_at t = Some next, then for the minimum alarm timeminthat occurs int, it is guaranteed that:next - alarm_precision t <= min < next.next_alarm_fires_at_exnis the same asnext_alarm_fires_at, except that it raises ifis_empty t.
module Private : sig ... end