package picos

  1. Overview
  2. Docs
Pico scheduler interface

Install

Dune Dependency

Authors

Maintainers

Sources

picos-0.4.0.tbz
sha256=343a8b4759239ca0c107145b8e2cc94c14625fecc0b0887d3c40a9ab7537b8da
sha512=db22b0a5b3adc603c0e815c9011c779f892b9ace76be018b2198d3e24a7d96727c999701025fe5a5fd07d0b452cb7286fc50c939aba0e4dce809941e9ebc12a6

doc/picos.sync/Picos_sync/Mutex/index.html

Module Picos_sync.MutexSource

A mutex implementation for Picos.

ℹ️ This intentionally mimics the interface of Stdlib.Mutex. Unlike with the standard library mutex, blocking on this mutex potentially allows an effects based scheduler to run other fibers on the thread.

🏎️ The optional checked argument taken by most of the operations defaults to true. When explicitly specified as ~checked:false the mutex implementation may avoid having to obtain the current fiber, which can be expensive relative to locking or unlocking an uncontested mutex. Note that specifying ~checked:false on an operation may prevent error checking also on a subsequent operation.

Sourcetype t

Represents a mutual-exclusion lock or mutex.

Sourceval create : ?padded:bool -> unit -> t

create () returns a new mutex that is initially unlocked.

Sourceval lock : ?checked:bool -> t -> unit

lock mutex locks the mutex.

ℹ️ If the fiber has been canceled and propagation of cancelation is allowed, this may raise the cancelation exception before locking the mutex. If ~checked:false was specified, the cancelation exception may or may not be raised.

  • raises Sys_error

    if the mutex is already locked by the fiber. If ~checked:false was specified for some previous operation on the mutex the exception may or may not be raised.

Sourceval try_lock : ?checked:bool -> t -> bool

try_lock mutex locks the mutex in case the mutex is unlocked. Returns true on success and false in case the mutex was locked.

ℹ️ If the fiber has been canceled and propagation of cancelation is allowed, this may raise the cancelation exception before locking the mutex. If ~checked:false was specified, the cancelation exception may or may not be raised.

Sourceval unlock : ?checked:bool -> t -> unit

unlock mutex unlocks the mutex.

  • raises Sys_error

    if the mutex was locked by another fiber. If ~checked:false was specified for some previous operation on the mutex the exception may or may not be raised.

Sourceval protect : ?checked:bool -> t -> (unit -> 'a) -> 'a

protect mutex thunk locks the mutex, runs thunk (), and unlocks the mutex after thunk () returns or raises.

ℹ️ If the fiber has been canceled and propagation of cancelation is allowed, this may raise the cancelation exception before locking the mutex. If ~checked:false was specified, the cancelation exception may or may not be raised.

OCaml

Innovation. Community. Security.