module Mutex: Mutex
type t = Mutex.t
val create : unit -> t
val equal : t -> t -> bool
val lock : t -> unit
lock mtx locks mtx, possibly waiting for it to be released
first by another thread.
Raises Unix_error if lock attempts to acquire mtx recursively.
val try_lock : t -> bool
try_lock mtx like lock, but returns immediately with false
if the mutex is already being held by another thread, or acquires
the mutex and returns true otherwise.
Raises Unix_error if try_lock attempts to acquire mtx recursively.
val timedlock : t -> Time.t -> bool
timedlock mtx timeout like lock, but takes a timeout parameter.
Raises Unix_error if timedlock attempts to acquire mtx recursively.
Returns true if the mutex was acquired, or false when timeout
expires otherwise.
val unlock : t -> unit
unlock mtx unlocks mtx.
Raises Unix_error if unlock attempts to release an unacquired
mutex or a mutex held by another thread.
val am_holding_mutex : t -> bool
val critical_section : t -> f:(unit -> 'a) -> 'a
val update_signal : t -> Condition.t -> f:(unit -> 'a) -> 'a
update_signal mtx cnd ~f updates some state within a critical
section protected by mutex mtx using function f and signals
condition variable cnd after finishing. If f raises an exception,
the condition will NOT be signaled!
val update_broadcast : t -> Condition.t -> f:(unit -> 'a) -> 'a
update_broadcast mtx cnd ~f updates some state within a critical
section protected by mutex mtx using function f and broadcasts
condition variable cnd after finishing. If f raises an exception,
the condition will NOT be broadcast!