Module Picos_std_sync.Barrier

A poisonable barrier.

🏎ī¸ This uses a slim, low overhead implementation that should perform reasonably well in most cases.

type t

Represents a poisonable barrier.

val max_parties : int

Maximum number of participants that a barrier can be configured with.

val create : ?padded:bool -> int -> t

create parties creates a new barrier for given number of parties.

  • raises Invalid_argument

    in case the given number of parties is less than 1 or greater than max_parties.

val parties : t -> int

parties barrier returns the number of parties the barrier was created with.

exception Poisoned

Exception raised by await in case the barrier has become poisoned.

val await : t -> unit

await barrier awaits until the configured number of parties has called await on the barrier and returns, or raises Poisoned in case the barrier has become poisoned.

ℹī¸ If the await is canceled, then await will poison the barrier before reraising the cancelation exception.

val poison : t -> unit

poison barrier marks the barrier as poisoned. Concurrent and subsequent calls of await will raise the Poisoned exception.