package picos

  1. Overview
  2. Docs
Pico scheduler interface

Install

Dune Dependency

Authors

Maintainers

Sources

picos-0.6.0.tbz
sha256=3f5a08199cf65c2dae2f7d68f3877178f1da8eabf5376e15114e5a8958087dfa
sha512=ad24910c47ce614268c4268874bb918da7f8b5f03b3ad706bbf30323635262e94ddab6be24eaebbca706bfa82c0a517d4272b396459e020c185942125c9bdb7b

doc/picos/Picos/Fiber/Maybe/index.html

Module Fiber.MaybeSource

An unboxed optional fiber.

Sourcetype t

Either a fiber or nothing.

Sourceval nothing : t

Not a fiber.

Sourceval of_fiber : fiber -> t

of_fiber fiber casts the fiber into an optional fiber.

🏎️ This performs no allocations.

Sourceval to_fiber : t -> fiber

to_fiber casts the optional fiber to a fiber.

Sourceval current_if : bool option -> t

current_if checked returns nothing in case checked is Some false and otherwise of_fiber (Fiber.current ()).

Sourceval current_and_check_if : bool option -> t

current_check_if checked returns nothing in case checked is Some false and otherwise of_fiber (Fiber.current ()) and also calls Fiber.check on the fiber.

Sourceval or_current : t -> t

or_current maybe returns of_fiber (Fiber.current ()) in case maybe is nothing and otherwise returns maybe.

Sourceval to_fiber_or_current : t -> fiber

to_fiber_or_current maybe returns Fiber.current () in case maybe is nothing and otherwise returns the fiber that maybe was cast from.

Sourceval check : t -> unit

check maybe returns immediately if maybe is nothing and otherwise calls Fiber.check on the fiber.

Sourceval equal : t -> t -> bool

equal l r determines whether l and r are maybe equal. Specifically, if either l or r or both is nothing, then they are considered (maybe) equal. Otherwise l and r are compared for physical equality.

Sourceval unequal : t -> t -> bool

equal l r determines whether l and r are maybe unequal. Specifically, if either l or r or both is nothing, then they are considered (maybe) unequal. Otherwise l and r are compared for physical equality.

Design rationale

The fiber identity is often needed only for the purpose of dynamically checking against programming errors. Unfortunately it can be relative expensive to obtain the current fiber.

As a data point, in a benchmark that increments an int ref protected by a mutex, obtaining the fiber identity for the lock and unlock operations — that only need it for error checking purposes — roughly tripled the cost of an increment on a machine.

Using GADTs internally allows an optional fiber to be provided without adding overhead to operations on non-optional fibers and allows optional fibers to used without allocations at a very low cost.

OCaml

Innovation. Community. Security.

On This Page
  1. Design rationale