Namespaces
Variants

std::barrier<CompletionFunction>:: barrier

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
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
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
constexpr explicit barrier ( std:: ptrdiff_t expected,
CompletionFunction f = CompletionFunction ( ) ) ;
(1) (C++20 起)
barrier ( const barrier & ) = delete ;
(2) (C++20 起)
1) 将每个阶段的初始期望计数和第一阶段的当前期望计数均设置为 expected ,使用 std :: move ( f ) 初始化完成函数对象,随后启动第一阶段。若 expected 为负值或大于 max() ,则行为未定义。
2) 复制构造函数被删除。 barrier 既不可复制也不可移动。

参数

expected - 期望计数的初始值
f - 在阶段完成步骤中调用的完成函数对象

异常

1) CompletionFunction 的移动构造函数抛出的任何异常。

注释

expected 允许为零。然而,对此类 barrier 调用析构函数以外的任何非静态成员函数将导致未定义行为。换言之,此类 barrier 仅可被销毁。