[#absl-Barrier]
= xref:absl.adoc[absl]::Barrier
:relfileprefix: ../
:mrdocs:

A barrier that blocks threads until a threshold of threads reach it&period;

== Synopsis

Declared in `&lt;absl&sol;synchronization&sol;barrier&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Barrier;
----

== Description

This class creates a barrier which blocks threads until a prespecified threshold of threads (`num&lowbar;threads`) utilizes the barrier&period; A thread utilizes the `Barrier` by calling `Block()` on the barrier, which will block that thread&semi; no call to `Block()` will return until `num&lowbar;threads` threads have called it&period;

Exactly one call to `Block()` will return `true`, which is then responsible for destroying the barrier&semi; because stack allocation will cause the barrier to be deleted when it is out of scope, barriers should not be stack allocated&period;

Example&colon;

[,cpp]
----
// Main thread creates a `Barrier`:
barrier = new Barrier(num_threads);

// Each participating thread could then call:
if (barrier->Block()) delete barrier;  // Exactly one call to `Block()`
                                        // returns `true`; that call
                                        // deletes the barrier.
----
== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/Barrier/2constructor-0bb.adoc[`Barrier`]         [.small]#[constructor]#
| Constructors
| xref:absl/Barrier/operator_assign.adoc[`operator&equals;`]  [.small]#[deleted]#
| Deleted copy assignment&semi; `Barrier` is not copyable&period;
| xref:absl/Barrier/Block.adoc[`Block`] 
| Blocks the calling thread until the thread threshold is reached&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
