Module Lock

module Lock: sig .. end
Reentrant locks.

type t 
The type of (reentrant) locks.
val make_reentrant : bool -> t
Returns a new reentrant lock, the parameter indicates whether a fair ordering policy is requested.
val lock : t -> unit
Acquires the lock. Returns immediately if the lock is either not held by another thread, or already held by the current thread. Otherwise, the current thread is blocked until the holding thread releases the lock.
val lock_interruptibly : t -> unit
Similar to lock, except that some other thread may interrupt the current thread while blocked.

Raises Runtime.Interrupted if the thread is interrupted.

val new_condition : t -> Condition.t
Returns a new condition associated with the passed lock.
val try_lock : t -> bool
Acquires the lock if available, returning true. Otherwise, immediately returns false.
val try_lock_time : t -> int64 -> TimeUnit.t -> bool
try_lock_time l t u is similar to lock_interruptibly l, except that the current thread will at most wait for t (time value whose unit is u). Returns whether the lock was acquired.

Raises Runtime.Interrupted if the thread is interrupted.

val unlock : t -> unit
Releases the lock.

Raises Invalid_argument if the current thread does not hold the lock.