include Async_kernel__.Time_source_intf.Time_source
module T1 : sig ... end
A time source has a phantom read-write parameter, where write
gives permission to
call advance
and fire_past_alarms
.
module Read_write : sig ... end
include sig ... end
val sexp_of_t : t ‑> Sexplib.Sexp.t
val read_only : [> Core_kernel.read ] T1.t ‑> t
val create : ?timing_wheel_config:Core_kernel.Timing_wheel_ns.Config.t ‑> now:Async_kernel__.Import.Time_ns.t ‑> unit ‑> Core_kernel.read_write T1.t
val wall_clock : unit ‑> t
A time source with now t
given 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 to wall_clock ()
returns the same value. The behavior of now
is special for wall_clock ()
; it
always calls Time_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.t
Accessors. now (wall_clock ())
behaves specially; see wall_clock
above.
val next_alarm_fires_at : [> Core_kernel.read ] T1.t ‑> Async_kernel__.Import.Time_ns.t option
val now : [> Core_kernel.read ] T1.t ‑> Async_kernel__.Import.Time_ns.t
val advance : [> Core_kernel.write ] T1.t ‑> to_:Async_kernel__.Import.Time_ns.t ‑> unit
val advance_by : [> Core_kernel.write ] T1.t ‑> Async_kernel__.Import.Time_ns.Span.t ‑> unit
val fire_past_alarms : [> Core_kernel.write ] T1.t ‑> unit
val advance_by_alarms : [> Core_kernel.write ] T1.t ‑> to_:Async_kernel__.Import.Time_ns.t ‑> unit Async_kernel__.Time_source_intf.Deferred.t
advance_by_alarms t
repeatedly calls advance t
to drive the time forward in
steps, where each step is the minimum of to_
and the next alarm time. After each
step, advance_by_alarms
waits on Scheduler.yield ()
to allow a chance for the
triggered alarms to run before moving forward, which also allows triggered timers to
execute and potentially rearm for subsequent steps. The returned deferred is filled
when to_
is reached.
advance_by_alarms
is useful in simulation when one wants to efficiently advance to
a time in the future while giving periodic timers (e.g. resulting from every
) a
chance to fire with approximately the same timing as they would live.
module Continue : sig ... end
val 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 ‑> unit
See Clock.every' for documentation.
The functions below here are the same as in clock_intf.ml, except they take an
explicit t
argument. See clock_intf.ml for documentation.
val run_at : [> Core_kernel.read ] T1.t ‑> Async_kernel__.Import.Time_ns.t ‑> ('a ‑> unit) ‑> 'a ‑> unit
val run_after : [> Core_kernel.read ] T1.t ‑> Async_kernel__.Import.Time_ns.Span.t ‑> ('a ‑> unit) ‑> 'a ‑> unit
val at : [> Core_kernel.read ] T1.t ‑> Async_kernel__.Import.Time_ns.t ‑> unit Async_kernel__.Time_source_intf.Deferred.t
val after : [> Core_kernel.read ] T1.t ‑> Async_kernel__.Import.Time_ns.Span.t ‑> unit Async_kernel__.Time_source_intf.Deferred.t
val 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 ... end
val 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.t
val 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.t
val 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) ‑> unit
See 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) ‑> unit
val 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) ‑> unit
val 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) ‑> unit