package fiber

  1. Overview
  2. Docs
type t

Pool is used to submit asynchronous tasks without waiting for their completion.

val create : unit -> t

Create a new pool.

val running : t -> bool fiber

running pool returns whether it's possible to submit tasks to pool

val task : t -> f:(unit -> unit fiber) -> unit fiber

task pool ~f submit f to be done in pool. Errors raised pool will not be raised in the current fiber, but inside the Pool.run fiber.

If running pool returns false, this function will raise a Code_error.

val stop : t -> unit fiber

stop pool stops the pool from receiving new tasks. After this function is called, task pool ~f will fail to submit new tasks.

Note that stopping the pool does not prevent already queued tasks from running.

val run : t -> unit fiber

run pool Runs all tasks submitted to pool in parallel. Errors raised by such tasks must be caught here.

OCaml

Innovation. Community. Security.