module Mutex: sig end
Mutexes (mutual-exclusion locks) are used to implement critical sections
and protect shared mutable data structures against concurrent accesses.
The typical use is (if m
is the mutex associated with the data structure
D
):
Mutex.lock m;
(* Critical section that operates over D *);
Mutex.unlock m
type
t
val create : unit -> t
val lock : t -> unit
val try_lock : t -> bool
Mutex.lock
, but does not suspend the calling thread if
the mutex is already locked: just return false
immediately
in that case. If the mutex is unlocked, lock it and
return true
.val unlock : t -> unit