github ↗
docs menu

Module Rig_nv.Lock

#type t

The type for a path's locks.

#val create : unit -> t

create () is a new lock. A thread may take it while it holds an image's lock or a device's local memory lock.

#val protect : t -> (unit -> 'a) -> 'a

protect l f is f () run holding l, which it gives back as f returns or raises. A path holds one of its locks at a time.

Raises Invalid_argument, having taken nothing, if the calling thread holds a path's lock, l included.

#val try_protect : t -> (unit -> unit) -> bool

try_protect l f is true once f () ran as in protect, or false, having run nothing, if another thread holds l or the calling thread holds a path's lock. It never waits.

#val guarded : string -> (unit -> 'a) -> 'a

guarded fn f is f () run with the calling thread's signals blocked but inside the path's waits (Drivers), except on Windows, where OCaml has no signal masks and it blocks none. It raises Invalid_argument, naming fn, having run nothing, if the calling thread holds a lock of rig's or of a driver's. A path calls it as A path's locks states.