package miou

  1. Overview
  2. Docs
Composable concurrency primitives for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

miou-0.3.1.tbz
sha256=2b7a2d52ec0599156b6e7c586190cc99dd964d840799763f6f2407bb83e39471
sha512=eba70cb4c5484ef4c5fce522b106d32f20482fe55a9252c82cf7b85d69cd1359d97a9d7279f39c05f3b2365d87cdfec39fbe2a0780167506d1eaeaf618227895

doc/miou.sync/Miou_sync/Trigger/index.html

Module Miou_sync.TriggerSource

Sourcetype t
Sourceval create : unit -> t

create () allocates a new trigger in the initial state.

Sourceval is_initial : t -> bool

is_initial t determines whether the trigger t is in the initial state.

Sourceval is_signaled : t -> bool

is_signaled t determines whether the trigger t is in the signaled state.

Sourceval await : t -> (exn * Printexc.raw_backtrace) option

await t waits for the trigger to be signaled.

The return value is None in case the trigger was signaled before await or we resumed the underlying continuation normally. Otherwise, the return value is Some (exn, bt), which indicates that the underlying continuation has been cancelled and the caller should raise the exception. In either case, the caller is responsible for cleaning up. Usually this means making sure that no references to the trigger remain to avoid space leak.

  • raises Invalid_argument

    if the trigger was in the awaiting state, which means that multiple concurrent calls of await are being made.

Sourcetype Effect.t += private
  1. | Await : t -> (exn * Printexc.raw_backtrace) option Effect.t
Sourceval signal : t -> unit

After signal t returns, the trigger has been put into the signaled state and any attached action (via on_signal) has been called.

Note that under normal circumstance, signal should never raise an exception. If an exception is raised by signal, it means that the attached action raised an error.

Sourceval on_signal : t -> 'x -> 'y -> (t -> 'x -> 'y -> unit) -> bool

on_signal t x y fn attempts to attach the fn action to the trigger t and transition the trigger to the awaiting state. It must be safe to call fn t x y from any context that signal might be called from.

The return value is true in case the action was attached successfully. Otherwise, the return value is false, which means that the trigger was already in the signaled state.

  • raises Invalid_argument

    if the trigger was in the awaiting state, which means that either the owner or creator of the trigger made concurrent calls to await or the handler called on_signal more than once.

OCaml

Innovation. Community. Security.