package eio

  1. Overview
  2. Docs
Effect-based direct-style IO API for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

eio-1.6.tbz
sha256=c1f04986b401094176494863dde1ca9b292b59fdc679a9d7023e558d80fb5b15
sha512=92ed8cf20300b8a4e0141bdbc373c0803c5a24530cb65852637d905fff4a5b956a8859a00a424034ff78c1112da9b0391194bcd558326168bdebd1ce683a8890

doc/eio/Eio/Lazy/index.html

Module Eio.LazySource

Delayed evaluation.

This is like Stdlib.Lazy, but multiple fibers or domains can force at once.

Sourcetype 'a t

A lazy value that produces a value of type 'a.

Sourceval from_fun : cancel:[ `Restart | `Record | `Protect ] -> (unit -> 'a) -> 'a t

from_fun ~cancel fn is a lazy value that runs fn () the first time it is forced.

cancel determines how cancellation is handled while forcing:

  • `Restart : if the forcing fiber is cancelled, the next waiting fiber runs fn again.
  • `Record : the failure is recorded and the lazy value will always report cancelled if used.
  • `Protect : the forcing fiber is protected from cancellation while running.
Sourceval from_val : 'a -> 'a t

from_val v is a lazy value that is already forced.

It is equivalent to from_fun (fun () -> v).

Sourceval force : 'a t -> 'a

force t returns the result of running the function passed to from_fun.

If the function is currently running, this waits for it to finish and then retries. If the function has already completed then it returns the saved result. If the function returned an exception then force re-raises it.