package async_kernel
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=30753e014bb0b127ee59f10b1073b8ae476468fb2f07dc8c99dbe2ef312fc696
doc/async_kernel/Async_kernel/index.html
Module Async_kernel
Source
Contains Async's core data structures, like Deferred
, Ivar
, and Clock
.
Async_kernel
is designed to depend only on Core
and so is more platform-independent.
Deprecates functions that use wall-clock time, so that code must be explicit about what time source is used.
The Async scheduler is responsible for running Async jobs. It maintains the queue of jobs that need to run. A "cycle" consists of running some (possibly all) jobs in the queue, along with some other bookkeeping, like advancing Async's clock to the current time.
A Bvar
is a synchronization point that allows one to broadcast
a value to clients wait
ing on the broadcast. With a Bvar
, one can efficiently notify multiple clients of edge-triggered conditions, repeating as each edge trigger occurs.
Async's implementation of the standard notion of a "condition" variable.
The context in which an Async job runs.
A write-once cell that can be empty or full (i.e., hold a single value).
A delayed computation that can produce a deferred.
Monad_sequence.S
is a generic interface specifying functions that deal with a container and a monad. It is specialized to the Deferred
monad and used with various containers in modules Deferred.Array
, Deferred.List
, Deferred.Queue
, and Deferred.Sequence
. The Monad_sequence.how
type specifies the parallelism of container iterators.
The part of the Execution_context
that determines what to do when there is an unhandled exception.
An Mvar
is a mutable location that is either empty or contains a value. One can put
or set
the value, and wait on value_available
for the location to be filled in either way.
A job's priority determines when in an async cycle the job is run. A "cycle" runs a bounded number of Normal
priority jobs followed by a bounded number of Low
priority jobs. The bound is Async_kernel_config.max_num_jobs_per_priority_per_cycle
.
An immutable sequence of values, with a possibly incomplete tail that may be extended asynchronously.
A synchronous version of Async_kernel.Time_source
. advance_by_alarms
runs alarms immediately, rather than enqueueing Async jobs.
A pointer to the end of an Async_stream
that can be used to extend the stream.
Toplevel functions
The functions below are broadly useful when writing Async programs, and so are made available at the toplevel.
val every :
?start:unit Deferred.t ->
?stop:unit Deferred.t ->
?continue_on_error:bool ->
Core.Core_private.Time_ns_alternate_sexp.Span.t ->
(unit -> unit) ->
unit
val schedule' :
?monitor:Monitor.t ->
?priority:Priority.t ->
(unit -> 'a Deferred.t) ->
'a Deferred.t
val try_with :
(?extract_exn:bool ->
?run:[ `Now | `Schedule ] ->
?rest:[ `Call of exn -> unit | `Log | `Raise ] ->
(unit -> 'a Deferred.t) ->
('a, exn) Core.Result.t Deferred.t)
Monitor.with_optional_monitor_name
val with_timeout :
Core.Core_private.Time_ns_alternate_sexp.Span.t ->
'a Deferred.t ->
'a Clock_ns.Or_timeout.t Deferred.t
val within' :
?monitor:Monitor.t ->
?priority:Priority.t ->
(unit -> 'a Deferred.t) ->
'a Deferred.t
Infix operators and Let_syntax
support
include Core.Monad.Infix with type 'a t := 'a Deferred.t
equivalent to Deferred.upon
.
val (>>=?) :
('a, 'b) Deferred.Result.t ->
('a -> ('c, 'b) Deferred.Result.t) ->
('c, 'b) Deferred.Result.t
equivalent to Deferred.Result.bind
.
equivalent to Deferred.Result.map
.
include module type of struct include Deferred.Let_syntax end
val (>>=) : 'a Deferred.t -> ('a -> 'b Deferred.t) -> 'b Deferred.t
val (>>|) : 'a Deferred.t -> ('a -> 'b) -> 'b Deferred.t