package picos

  1. Overview
  2. Docs
Pico scheduler interface

Install

Dune Dependency

Authors

Maintainers

Sources

picos-0.4.0.tbz
sha256=343a8b4759239ca0c107145b8e2cc94c14625fecc0b0887d3c40a9ab7537b8da
sha512=db22b0a5b3adc603c0e815c9011c779f892b9ace76be018b2198d3e24a7d96727c999701025fe5a5fd07d0b452cb7286fc50c939aba0e4dce809941e9ebc12a6

doc/picos.structured/Picos_structured/Bundle/index.html

Module Picos_structured.BundleSource

A dynamic bundle of fibers guaranteed to be joined at the end.

Bundles allow you to conveniently structure or delimit concurrency into nested scopes. After a bundle returns or raises an exception, no fibers forked to the bundle remain.

An unhandled exception, or error, within any fiber of the bundle causes all the fibers forked to the bundle to be canceled and the bundle to raise the exception.

Sourcetype t

Represents a bundle of fibers.

Sourceval join_after : (t -> 'a) -> 'a

join_after scope calls scope with a bundle. A call of join_after returns or raises only after scope has returned or raised and all forked fibers have terminated. If scope raises an exception, error will be called.

ℹ️ When scope returns normally, terminate will not be called implicitly.

Sourceval terminate : ?callstack:int -> t -> unit

terminate bundle cancels all the forked fibers using the Terminate exception. After terminate has been called, no new fibers can be forked to the bundle.

The optional callstack argument specifies the number of callstack entries to capture with the Terminate exception. The default is 0.

ℹ️ Calling terminate at the end of a bundle can be a convenient way to cancel any background fibers started by the bundle.

ℹ️ Calling terminate does not raise the Terminate exception, but blocking operations after terminate will raise the exception to propagate cancelation unless propagation of cancelation is forbidden.

Sourceval error : ?callstack:int -> t -> Picos.Exn_bt.t -> unit

error bundle exn_bt first calls terminate and then adds the exception with backtrace to the list of exceptions to be raised, unless the exception is the Terminate exception, which is not considered to signal an error by itself.

The optional callstack argument is passed to terminate.

Sourceval fork_as_promise : t -> (unit -> 'a) -> 'a Promise.t

fork_as_promise bundle thunk spawns a new fiber to the bundle that will run the given thunk. The result of the thunk will be written to the promise. If the thunk raises an exception, error will be called with that exception.

Sourceval fork : t -> (unit -> unit) -> unit

fork bundle action is equivalent to fork_as_promise bundle action |> ignore.

OCaml

Innovation. Community. Security.