package fuseau

  1. Overview
  2. Docs

Module Fuseau.FiberSource

Fibers.

A fiber is a lightweight cooperative thread. It runs on the scheduler and can yield to other fibers, notably on IO polling points.

Sourcetype 'a t = 'a Fuseau__.Types.fiber

A fiber returning a value of type 'a.

Sourcetype any = Fuseau__.Types.any_fiber =
  1. | Any_fiber : _ t -> any

A fiber with erased return type.

Sourcetype 'a callback = 'a Exn_bt.result -> unit

Callbacks that are called when a fiber is done.

Sourcetype cancel_callback = Exn_bt.t -> unit
Sourceval return : 'a -> 'a t
Sourceval fail : Exn_bt.t -> _ t
Sourceval peek : 'a t -> 'a Exn_bt.result option
Sourceval is_cancelled : _ t -> bool
Sourceval is_done : _ t -> bool
Sourceexception Cancelled of Exn_bt.t

Exception for fibers that are cancelled. Polling points such as yield and await will raise this if the fiber has been cancelled.

Sourceval on_res : 'a t -> 'a callback -> unit

Wait for fiber to be done and call the callback with the result. If the fiber is done already then the callback is invoked immediately with its result.

Sourceval get_current : unit -> any

get_current () returns the currently running fiber.

  • raises Failure

    if called from outside a fiber

OCaml

Innovation. Community. Security.