Module Luv.Mutex
Mutexes.
See Synchronization primitives in the user guide and Mutex locks in libuv.
type t
= Luv__.C.Types.Mutex.t Ctypes.ptr
Binds
uv_mutex_t
.
val init : ?recursive:bool -> unit -> (t, Error.t) Result.result
Allocates and initializes a mutex.
Binds
uv_mutex_init
. Seepthread_mutex_init(3p)
.If
?recursive
is set totrue
, callsuv_mutex_init_recursive
instead.?recursive
requires libuv 1.15.0.Feature check:
Luv.Require.(has mutex_init_recursive)
val destroy : t -> unit
Cleans up a mutex.
Binds
uv_mutex_destroy
. Seepthread_mutex_destroy(3p)
.
val lock : t -> unit
Takes a mutex.
Binds
uv_mutex_lock
. Seepthread_mutex_lock(3p)
.The calling thread is blocked until it obtains the mutex.
val trylock : t -> (unit, Error.t) Result.result
Tries to take the mutex without blocking.
Binds
uv_mutex_trylock
. Seepthread_mutex_trylock(3p)
.
val unlock : t -> unit
Releases the mutex.
Binds
uv_mutex_unlock
. Seepthread_mutex_unlock(3p)
.