module CyclicBarrier: sig .. end
Reusable barriers.
type t
The type of cyclic barriers, that are barriers possibly re-used once
all waiting threads have restarted.
val make : int32 -> t
make n
returns a barrier waiting for n
threads.
Raises Invalid_argument
if n
is negative.
val await : t -> int32
Waits until all threads have reached the barrier.
Raises Invalid_argument
if the barrier is broken.
Raises Runtime.Interrupted
if the thread is interrupted.
val await_time : t -> int64 -> TimeUnit.t -> int32
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
).
Raises Invalid_argument
if the barrier is broken.
Raises Runtime.Interrupted
if the thread is interrupted.
Raises Runtime.Timeout
if time has elapsed without gathering all
threads.
val get_number_waiting : t -> int32
Returns the number of threads currently waiting on the barrier.
val get_parties : t -> int32
Returns the number of threads to be waited on the barrier.
val is_broken : t -> bool
Tests whether the barrier is broken. A barrier is broken if reset
when threads are waiting on it.
val reset : t -> unit
Resets the barrier to its original state. The barrier will be broken
if there are threads currently waiting on it.