Module ReadWriteLock

module ReadWriteLock: sig .. end
Read/write locks.

type t = java'util'concurrent'locks'ReentrantReadWriteLock java_instance
The type of read/write locks that are indeed peirs of associated locks where the read lock can be held simultaneously by any number of threads as long as the write lock is available, while the write lock can be help by at most one thread at a time.
val make_reentrant : ?fair:bool -> unit -> t
Returns a new read/write lock, whose read and write locks are reentrant, the parameter indicates whether a fair ordering policy is requested (defaulting to false); see ReentrantReadWriteLock(...).
val read_lock : t -> Lock.t
Returns the read lock of the read/write lock; see readLock(...).
val write_lock : t -> Lock.t
Returns the write lock of the read/write lock; see writeLock(...).

Null value

val null : t
The null value.
val is_null : t -> bool
is_null obj returns true iff obj is equal to null.
val is_not_null : t -> bool
is_not_null obj returns false iff obj is equal to null.


val wrap : t -> t option
wrap obj wraps the reference obj into an option type:
  • Some x if obj is not null;
  • None if obj is null.

val unwrap : t option -> t
unwrap obj unwraps the option obj into a bare reference:
  • Some x is mapped to x;
  • None is mapped to null.