Module Condition

module Condition: sig .. end
Lock-base condition.

type t = java'util'concurrent'locks'Condition java_instance
The type of conditions, constructed from Lock values.

Operations on conditions should be called only when the lock the condition was constructed from is held by the current thread.
 
val await : t -> unit
Waits until either the condition is signal, or the current thread is interrupted; see await(...).
Raises
  • Java_exception if the current thread does not hold the associated lock
  • Java_exception if the thread is interrupted
 
val await_time : t -> java_long -> TimeUnit.t -> bool
await_time c t u is similar to await c, except that the current thread will at most wait for t (time value whose unit is u). Returns whether the condition was signaled; see await(...).
Raises
  • Java_exception if the current thread does not hold the associated lock
  • Java_exception if the thread is interrupted
 
val await_nanos : t -> java_long -> java_long
await_nanos c n is similar to await c, except that the current thread will at most wait for n nanoseconds. Returns the duration of the wait, a negative value if the condition was not signaled; see awaitNanos(...).
Raises
  • Java_exception if the current thread does not hold the associated lock
  • Java_exception if the thread is interrupted
 
val await_uninterruptibly : t -> unit
Similar to await except that the thread cannot be interrupted; see awaitUninterruptibly(...).
Raises Java_exception if the current thread does not hold the associated lock
 
val await_until : t -> JavaDate.t -> bool
await_until c d waits until the date d is reached. Returns whether the date was actually reached; see awaitUntil(...).
Raises
  • Java_exception if the current thread does not hold the associated lock
  • Java_exception if the thread is interrupted
 
val signal : t -> unit
Signals the condition, unblocking one waiting thread; see signal(...).
Raises Java_exception if the current thread does not hold the associated lock
 
val signal_all : t -> unit
Signals the condition, unblocking all waiting threads; see signalAll(...).
Raises Java_exception if the current thread does not hold the associated lock
 

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.
 

Miscellaneous

 
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.