package picos_std
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0
doc/picos_std.sync/Picos_std_sync/Mutex/index.html
Module Picos_std_sync.Mutex
Source
A mutual-exclusion lock or mutex.
ℹ️ 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.
Represents a mutual-exclusion lock or mutex.
create ()
returns a new mutex that is initially unlocked.
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.
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.
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.