package b0

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module B0_zero.ExecSource

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

Sourcetype feedback = [
  1. | `Exec_start of B0_std.Os.Cmd.pid option * Op.t
]

The type for executor feedbacks. Indicates the given operation starts executig with, for spawn operations, their operating system process identifier.

Sourcetype t

The type for executors.

Sourceval make : ?clock:B0_std.Os.Mtime.counter -> ?rand:Random.State.t -> ?tmp_dir:B0_std.Fpath.t -> ?feedback:(feedback -> unit) -> trash:Trash.t -> jobs:int -> unit -> t

make ~clock ~rand ~tmp_dir ~feedback ~trash ~jobs with:

clock e is e's clock.

Sourceval tmp_dir : t -> B0_std.Fpath.t

tmp_dir e is e's temporary directory.

Sourceval trash : t -> Trash.t

trash e is e's trash.

Sourceval jobs : t -> int

jobs e is e's maximal number of simultaneous process spawns.

Scheduling and collecting operations

Sourceval schedule : t -> Op.t -> unit

schedule e o schedules o for execution in e. When o starts executing it is given to the feedback callback of e (see make).

Sourceval collect : t -> block:bool -> 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.