···77 val unlock : t -> unit
88 val try_lock : t -> bool
99 val protect : t -> (unit -> 'a) -> 'a
1010- val lock_all : t list -> bool
1110end
12111312module Stdlib : MUTEX = struct
1413 include Mutex
15141616- let lock_all mutexes =
1717- let rec try_lock_all acc = function
1818- | [] ->
1919- (* All mutexes acquired successfully *)
2020- true
2121- | mutex :: rest ->
2222- if try_lock mutex then
2323- try_lock_all (mutex :: acc) rest
2424- else begin
2525- (* Failed to acquire current mutex, release all previously acquired ones *)
2626- List.iter unlock acc;
2727- false
2828- end
2929- in
3030- try_lock_all [] mutexes
1515+3116end
32173318(* Picos implementation - only available if picos is linked *)
-16
forks/lwd/lib/lwd/mutex_stdlib.ml
···11(** OCaml standard library implementation of the mutex interface. *)
2233include Mutex
44-55-let lock_all mutexes =
66- let rec try_lock_all acc = function
77- | [] ->
88- (* All mutexes acquired successfully *)
99- true
1010- | mutex :: rest ->
1111- if try_lock mutex then
1212- try_lock_all (mutex :: acc) rest
1313- else begin
1414- (* Failed to acquire current mutex, release all previously acquired ones *)
1515- List.iter unlock acc;
1616- false
1717- end
1818- in
1919- try_lock_all [] mutexes
-15
forks/lwd/lib/lwd_picos/mutex_picos.ml
···1818let try_lock mut = try_lock mut
1919let protect mut f = protect mut f
20202121-let lock_all mutexes =
2222- let rec try_lock_all acc = function
2323- | [] ->
2424- (* All mutexes acquired successfully *)
2525- true
2626- | mutex :: rest ->
2727- if try_lock mutex then
2828- try_lock_all (mutex :: acc) rest
2929- else begin
3030- (* Failed to acquire current mutex, release all previously acquired ones *)
3131- List.iter unlock acc;
3232- false
3333- end
3434- in
3535- try_lock_all [] mutexes
-15
forks/lwd/lib/lwd_stdlib/mutex_stdlib.ml
···2233include Mutex
4455-let lock_all mutexes =
66- let rec try_lock_all acc = function
77- | [] ->
88- (* All mutexes acquired successfully *)
99- true
1010- | mutex :: rest ->
1111- if try_lock mutex then
1212- try_lock_all (mutex :: acc) rest
1313- else begin
1414- (* Failed to acquire current mutex, release all previously acquired ones *)
1515- List.iter unlock acc;
1616- false
1717- end
1818- in
1919- try_lock_all [] mutexes