package b0

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

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 = [
  1. | `Exec_start of B00_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.

type t

The type for executors.

val create : ?clock:B00_std.Time.counter -> ?rand:Random.State.t -> ?tmp_dir:B00_std.Fpath.t -> ?feedback:(feedback -> unit) -> trash:Trash.t -> jobs:int -> unit -> t

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

  • clock, the clock used to timestamp build operations; defaults to B00_std.Time.counter ().
  • rand random state used for internal queues; defaults to Random.State.make_self_init.
  • tmp_dir is a directory for temporary files, it must exist; defaults to B00_std.Os.Dir.default_tmp ().
  • feedback a function called with each scheduled operation when it starts executing. Default is a nop.
  • trash, the trash used to execute Op.kind.Delete build operations.
  • jobs the maximal number of processes spawn simultaneously.
val clock : t -> B00_std.Time.counter

clock e is e's clock.

val tmp_dir : t -> B00_std.Fpath.t

tmp_dir e is e's temporary directory.

val trash : t -> Trash.t

trash e is e's trash.

val jobs : t -> int

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

Scheduling and collecting operations

val 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 create).

val 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.

OCaml

Innovation. Community. Security.