module Nano_mutex: Nano_mutex
type
t
val invariant : t -> unit
val create : unit -> t
create ()
returns a new, unlocked mutex.
val equal : t -> t -> bool
equal
is phys_equal
val current_thread_has_lock : t -> bool
current_thread_has_lock t
returns true
iff the current thread has t
locked.
val lock : t -> unit Core_kernel.Std.Or_error.t
lock t
locks the mutex t
, blocking until it can be locked. lock
immediately
returns Error
if the current thread already holds t
.
val lock_exn : t -> unit
val try_lock : t -> [ `Acquired | `Not_acquired ] Core_kernel.Std.Or_error.t
try_lock t
locks t
if it can immediately do so. The result indicates whether
try_lock
succeeded in acquiring the lock. try_lock
returns Error
if the current
thread already holds t
.
val try_lock_exn : t -> [ `Acquired | `Not_acquired ]
val unlock : t -> unit Core_kernel.Std.Or_error.t
unlock t
unlocks t
, if the current thread holds it. unlock
returns Error
if
the lock is not held by the calling thread.
val unlock_exn : t -> unit
val critical_section : t -> f:(unit -> 'a) -> 'a
val sexp_of_t : t -> Sexplib.Sexp.t
create ()
returns a new, unlocked mutex.
equal
is phys_equal
current_thread_has_lock t
returns true
iff the current thread has t
locked.
lock t
locks the mutex t
, blocking until it can be locked. lock
immediately
returns Error
if the current thread already holds t
.
try_lock t
locks t
if it can immediately do so. The result indicates whether
try_lock
succeeded in acquiring the lock. try_lock
returns Error
if the current
thread already holds t
.
unlock t
unlocks t
, if the current thread holds it. unlock
returns Error
if
the lock is not held by the calling thread.