Module Async_kernel.Time_source
module T1 : sig ... endA time source has a phantom read-write parameter, where
writegives permission to calladvanceandfire_past_alarms.
module Read_write : sig ... endtype t= Core_kernel.read T1.t
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val invariant_with_jobs : job:Async_kernel__.Job.t Core_kernel.Invariant.t -> t Core_kernel.Invariant.tval read_only : [> Core_kernel.read ] T1.t -> tval create : ?timing_wheel_config:Core_kernel.Timing_wheel_ns.Config.t -> now:Async_kernel__.Import.Time_ns.t -> unit -> Core_kernel.read_write T1.tval wall_clock : unit -> tA time source with
now tgiven by wall-clock time (i.e.,Time_ns.now) and that is advanced automatically as time passes (specifically, at the start of each Async cycle). There is only one wall-clock time source; every call towall_clock ()returns the same value. The behavior ofnowis special forwall_clock (); it always callsTime_ns.now (), so it can return times that the time source has not yet been advanced to.
val alarm_precision : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.tval next_alarm_fires_at : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.t optionval now : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.tval timing_wheel_now : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.tRemoves the special behavior of
nowforwall_clock; it always returns the timing_wheel's notion of now.
val advance : [> Core_kernel.write ] T1.t -> to_:Async_kernel__.Import.Time_ns.t -> unitUnlike in
Synchronous_time_source, theadvancefunction here only approximately determines the set of events to fire. You should also callfire_past_alarmsif you want precision (see docs forTiming_wheel_ns.advance_clockvs.Timing_wheel_ns.fire_past_alarms).
val advance_by : [> Core_kernel.write ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> unitval fire_past_alarms : [> Core_kernel.write ] T1.t -> unitval advance_by_alarms : ?wait_for:(unit -> unit Async_kernel__.Time_source_intf.Deferred.t) -> [> Core_kernel.write ] T1.t -> to_:Async_kernel__.Import.Time_ns.t -> unit Async_kernel__.Time_source_intf.Deferred.tadvance_by_alarms trepeatedly callsadvance tto drive the time forward in steps, where each step is the minimum ofto_and the next alarm time. After each step,advance_by_alarmswaits for the result ofwait_forto become determined before advancing. By default,wait_forwill beScheduler.yield ()to allow the triggered timers to execute and potentially rearm for subsequent steps. The returned deferred is filled whento_is reached.advance_by_alarmsis useful in simulation when one wants to efficiently advance to a time in the future while giving periodic timers (e.g., resulting fromevery) a chance to fire with approximately the same timing as they would live.
module Continue : sig ... endval run_repeatedly : ?start:unit Async_kernel__.Time_source_intf.Deferred.t -> ?stop:unit Async_kernel__.Time_source_intf.Deferred.t -> ?continue_on_error:bool -> ?finished:unit Ivar.t -> [> Core_kernel.read ] T1.t -> f:(unit -> unit Async_kernel__.Time_source_intf.Deferred.t) -> continue:Continue.t -> unitSee
Clock.everyfor documentation.
val run_at : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.t -> ('a -> unit) -> 'a -> unitval run_after : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> ('a -> unit) -> 'a -> unitval at : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.t -> unit Async_kernel__.Time_source_intf.Deferred.tval after : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> unit Async_kernel__.Time_source_intf.Deferred.tval with_timeout : [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> 'a Async_kernel__.Time_source_intf.Deferred.t -> [ `Timeout | `Result of 'a ] Async_kernel__.Time_source_intf.Deferred.t
module Event : sig ... endval at_varying_intervals : ?stop:unit Async_kernel__.Time_source_intf.Deferred.t -> [> Core_kernel.read ] T1.t -> (unit -> Async_kernel__.Import.Time_ns.Span.t) -> unit Async_kernel__.Async_stream.tval at_intervals : ?start:Async_kernel__.Import.Time_ns.t -> ?stop:unit Async_kernel__.Time_source_intf.Deferred.t -> [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> unit Async_kernel__.Async_stream.tval every' : ?start:unit Async_kernel__.Time_source_intf.Deferred.t -> ?stop:unit Async_kernel__.Time_source_intf.Deferred.t -> ?continue_on_error:bool -> ?finished:unit Ivar.t -> [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> (unit -> unit Async_kernel__.Time_source_intf.Deferred.t) -> unitSee
Clock.every' for documentation.
val every : ?start:unit Async_kernel__.Time_source_intf.Deferred.t -> ?stop:unit Async_kernel__.Time_source_intf.Deferred.t -> ?continue_on_error:bool -> [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> (unit -> unit) -> unitval run_at_intervals' : ?start:Async_kernel__.Import.Time_ns.t -> ?stop:unit Async_kernel__.Time_source_intf.Deferred.t -> ?continue_on_error:bool -> [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> (unit -> unit Async_kernel__.Time_source_intf.Deferred.t) -> unitval run_at_intervals : ?start:Async_kernel__.Import.Time_ns.t -> ?stop:unit Async_kernel__.Time_source_intf.Deferred.t -> ?continue_on_error:bool -> [> Core_kernel.read ] T1.t -> Async_kernel__.Import.Time_ns.Span.t -> (unit -> unit) -> unitval of_synchronous : 'a Synchronous_time_source.T1.t -> 'a T1.tTime_sourceandSynchronous_time_sourceare the same data structure and use the same underlying timing wheel. The types are freely interchangeable.
val to_synchronous : 'a T1.t -> 'a Synchronous_time_source.T1.t