Module CyclicBarrier

module CyclicBarrier: sig .. end
Reusable barriers.

type t = java'util'concurrent'CyclicBarrier java_instance
The type of cyclic barriers, that are barriers possibly re-used once all waiting threads have restarted.
 
val make : java_int -> t
make n returns a barrier waiting for n threads; see CyclicBarrier(...).
Raises Java_exception if n is negative
 
val await : t -> java_int
Waits until all threads have reached the barrier; see await(...).
Raises
  • Java_exception if the barrier is broken
  • Java_exception if the thread is interrupted
 
val await_time : t -> java_long -> TimeUnit.t -> java_int
await_time b t u is similar to await b, except that the current thread will at most wait for t (time value whose unit is u); see await(...).

@Raises Java_exception if the barrier is broken. @Raises Java_exception if the thread is interrupted. @Raises Java_exception if time has elapsed without gathering all threads
 
val get_number_waiting : t -> java_int
Returns the number of threads currently waiting on the barrier; see getNumberWaiting(...).
 
val get_parties : t -> java_int
Returns the number of threads to be waited on the barrier; see getParties(...).
 
val is_broken : t -> bool
Tests whether the barrier is broken. A barrier is broken if CyclicBarrier.reset when threads are waiting on it; see isBroken(...).
 
val reset : t -> unit
Resets the barrier to its original state. The barrier will be broken if there are threads currently waiting on it; see reset(...).
 

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.