A barrier you can reuse
A plain barrier or countdown latch fires once. A cyclic barrier automatically resets after every group rendezvous, so the same set of threads can synchronize round after round.
How a round works
- Threads arrive and wait until the party size is reached.
- An optional barrier action runs once, on the last arriving thread, before release.
- The barrier resets its count and releases everyone for the next round.
This fits iterative algorithms where each pass must complete before the next begins, such as a parallel solver that exchanges boundary data between iterations.
Generations and failure
Each cycle is a generation. If one waiting thread is interrupted or times out, the barrier breaks the current generation and signals all the others with an exception, so no one is left stranded believing the round succeeded.
Key idea
A cyclic barrier rendezvous a fixed group, optionally runs a one time action, then resets for the next generation, making it the right tool for repeated phase synchronization in iterative work.