Namespaces
Variants
Views
Actions

std::barrier<CompletionFunction>::arrive_and_wait

From cppreference.com
< cpp‎ | thread‎ | barrier
Revision as of 11:23, 23 August 2021 by Ljestrada (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 
 
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
(C++11)
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
Safe Reclamation
(C++26)
Hazard Pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11)(deprecated in C++20)
(C++11)(deprecated in C++20)
Memory ordering
Free functions for atomic operations
Free functions for atomic flags
 
 
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.

Contents

[edit] Parameters

(none)

[edit] Return value

(none)

[edit] Exceptions

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

[edit] 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.

[edit] Example