···38 by another thread will suspend until the other thread unlocks
39 the mutex.
4041- @raise Sys_error if the mutex is already locked by the thread
42- calling {!Mutex.lock} on Unix platforms. On Windows, recursive
43- locking deadlocks.
4445 @before 4.12 {!Sys_error} was not raised for recursive locking
46- (platform-dependent behaviour).
47-48- @since 5.3 On Windows, {!Sys_error} is not raised for recursive
49- locking. *)
5051val try_lock : t -> bool
52(** Same as {!Mutex.lock}, but does not suspend the calling thread if
···58(** Unlock the given mutex. Other threads suspended trying to lock
59 the mutex will restart. The mutex must have been previously locked
60 by the thread that calls {!Mutex.unlock}.
61-62- @raise Sys_error if the mutex is unlocked or was locked by another
63- thread. This doesn't apply on Windows since OCaml 5.3.
6465 @before 4.12 {!Sys_error} was not raised when unlocking an unlocked mutex
66- or when unlocking a mutex from a different thread.
67-68- @since 5.3 On Windows, {!Sys_error} is not raised if the mutex is
69- unlocked or was locked by another thread. *)
7071val protect : t -> (unit -> 'a) -> 'a
72(** [protect mutex f] runs [f()] in a critical section where [mutex]
···38 by another thread will suspend until the other thread unlocks
39 the mutex.
4041+ @raise Sys_error if the mutex is already locked by the thread calling
42+ {!Mutex.lock}.
04344 @before 4.12 {!Sys_error} was not raised for recursive locking
45+ (platform-dependent behaviour) *)
0004647val try_lock : t -> bool
48(** Same as {!Mutex.lock}, but does not suspend the calling thread if
···54(** Unlock the given mutex. Other threads suspended trying to lock
55 the mutex will restart. The mutex must have been previously locked
56 by the thread that calls {!Mutex.unlock}.
57+ @raise Sys_error if the mutex is unlocked or was locked by another thread.
005859 @before 4.12 {!Sys_error} was not raised when unlocking an unlocked mutex
60+ or when unlocking a mutex from a different thread. *)
0006162val protect : t -> (unit -> 'a) -> 'a
63(** [protect mutex f] runs [f()] in a critical section where [mutex]
-1
testsuite/tests/lib-threads/mutex_errors.ml
···2 include systhreads;
3 hassysthreads;
4 no-tsan; (* tsan detects the mutex errors and fails *)
5- not-windows; (* Windows' SRWLock differ from pthreads ERRORCHECK mutexes. *)
6 {
7 bytecode;
8 }{
···2 include systhreads;
3 hassysthreads;
4 no-tsan; (* tsan detects the mutex errors and fails *)
05 {
6 bytecode;
7 }{