package algaeff

  1. Overview
  2. Docs

The signature of mutex effects.

exception Locked

The exception raised by exclusively if the mutex was locked.

val exclusively : (unit -> 'a) -> 'a

exclusively f locks the mutex, run the thunk f, and then unlock the mutex. If the mutex was already locked, exclusively f immediately raises Locked without waiting. Note that calling exclusively inside f is an instance of attempting to lock an already locked mutex.

  • raises Locked

    The mutex was already locked.

val run : (unit -> 'a) -> 'a

run f executes the thunk f which may perform mutex effects. Each call of run creates a fresh mutex; in particular, calling run inside the thunk f will start a new scope that does not interfere with the outer scope.

OCaml

Innovation. Community. Security.