# std::barrier<CompletionFunction>::arrive_and_wait

> C++ Atlas: `cppatlas.com/w/cpp/thread/barrier/arrive_and_wait` | Source: https://en.cppreference.com/w/cpp/thread/barrier/arrive_and_wait | Domain: Concurrency support | Standards: C++20

Atomically decrements the expected count by 1, then blocks at the synchronization point for the current phase until the phase completion step of the current phase is run.

## Official Specification Summary (cppreference)

```cpp
void arrive_and_wait(); // (since C++20)
```

Atomically decrements the expected count by 1, then blocks at the synchronization point for the current phase until the phase completion step of the current phase is run. Equivalent to `wait(arrive());`.

The behavior is undefined if the expected count for the current phase is zero.

### Parameters

(none)

### Return value

(none)

### Exceptions

Throws `std::system_error` with an error code allowed for mutex types on error.

### Notes

If the current expected count is decremented to zero in the call to this function, the phase completion step is run and this function does not block.

If the current expected count is zero before calling this function, the initial expected count for all subsequent phases is also zero, which means the `barrier` cannot be reused.

### Example

> Note: This section is incomplete Reason: no example

---
Attribution: content from https://en.cppreference.com/w/cpp/thread/barrier/arrive_and_wait (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.