Module B00.Exec
Build operation executors.
An executor is a parallel asynchronous work queue. It has no notion of synchronisation, any scheduled operation is randomly executed in parallel up to the executor's parallelizing limits.
Executors
type feedback
=[
|
`Exec_submit of B0_std.Os.Cmd.pid option * Op.t
]
The type for executor feedbacks.
val pp_feedback : feedback B0_std.Fmt.t
pp_feedback
formats executor feedback.
val create : ?clock:B0_std.Time.counter -> ?rand:Stdlib.Random.State.t -> ?tmp_dir:B0_std.Fpath.t -> ?feedback:(feedback -> unit) -> max_spawn:int -> unit -> t
create ~clock ~rand ~tmp_dir ~notify_submit ~max_spawn
with:max_spawn
the maximal number of processes spawn simultaneously.feedback
called with each scheduled operation when it gets submitted for execution. Default is a nop.tmp_dir
is a directory for temporary files, it must exist; defaults toB0_std.Os.Dir.default_tmp
()
.rand
random state used for internal queues; defaults toRandom
.State.make_self_init.clock
, the clock used to timestamp the operations; defaults toB0_std.Time.counter
()
.
val schedule : t -> Op.t -> unit
schedule e o
scheduleso
for execution ine
. Just beforeo
is actually submitted for execution it is given to thenotify_submit
callback ofe
(seecreate
).
val collect : t -> block:bool -> Op.t option
collect e ~block
removes frome
an operation that has completed (if any). Ifblock
isfalse
and no completed operation exists, the call returns immediately withNone
. Ifblock
istrue
and at least one incomplete operation exists ine
, the call blocks until an operation completes. Ifblock
istrue
and no operation exists ine
None
is returned.