module Exec:sig
..end
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.
typefeedback =
[ `Exec_submit of B0_std.Os.Cmd.pid option * B00.Op.t ]
val pp_feedback : feedback B0_std.Fmt.t
pp_feedback
formats executor feedback.type
t
val create : ?clock:B0_std.Time.counter ->
?rand: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 to B0_std.Os.Dir.default_tmp
()
.rand
random state used for internal queues; defaults to
Random.State.make_self_init
.clock
, the clock used to timestamp
the operations; defaults to B0_std.Time.counter
()
.val schedule : t -> B00.Op.t -> unit
schedule e o
schedules o
for execution in e
. Just before
o
is actually submitted for execution it is given to the
notify_submit
callback of e
(see B00.Exec.create
).val collect : t -> block:bool -> B00.Op.t option
collect e ~block
removes from e
an operation that has
completed (if any). If block
is false
and no completed
operation exists, the call returns immediately with None
. If
block
is true
and at least one incomplete operation exists
in e
, the call blocks until an operation completes. If block
is true
and no operation exists in e
None
is returned.