std::barrier<CompletionFunction>:: barrier
From cppreference.net
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::barrier
| Member functions | ||||
|
barrier::barrier
|
||||
| Constants | ||||
|
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
仅可被销毁。