package picos

  1. Overview
  2. Docs

Basic control operations and exceptions for structured concurrency.

exception Terminate

An exception that is used to signal fibers, typically by canceling them, that they should terminate by letting the exception propagate. This does not, by itself, indicate an error.

exception Errors of Picos.Exn_bt.t list

An exception that can be used to collect exceptions, typically indicating errors, from multiple fibers.

val raise_if_canceled : unit -> unit

raise_if_canceled () checks whether the current fiber has been canceled and if so raises the exception that the fiber was canceled with.

val yield : unit -> unit

yield () asks the current fiber to be rescheduled.

val sleep : seconds:float -> unit

sleep ~seconds suspends the current fiber for specified number of seconds.

val protect : (unit -> 'a) -> 'a

protect thunk forbids cancelation for the duration of thunk ().

val block : unit -> 'a

block () suspends the current fiber until it is canceled at which point the cancelation exception will be raised.

⚠️ Beware that protect block never returns and you don't want that.

OCaml

Innovation. Community. Security.