C++20 barrier

  • 01 C++20 barrier

01 C++20 barrier

下面是在 www.open-std.org 对 C++20 barrier 的一点介绍内容。(semaphores、latch、barrier)
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1135r2.html
1

barrier
屏障是一种线程协调机制,它最多允许阻止线程的预期计数,直到该计数由在其每个连续阶段中到达该屏障的线程(精确地)相加。一旦线程在某个阶段的同步点处从阻塞中释放出来,它们就可以在下一阶段立即重新使用同一屏障。[ 注意:因此,对于管理由多个线程处理的重复任务或较大任务的阶段非常有用。— 尾注 ]
屏障的完成步骤是与屏障的某个阶段关联的一组效果(可能是空的)。当本节中定义的成员函数到达障碍时,它们具有以下作用:
当此阶段的预期线程数到达屏障时,这些线程之一将执行屏障类型的完成步骤。

当完成步骤完成时,在此阶段在同步点被阻塞的所有线程都将被解除阻塞,并且屏障进入其下一阶段。完成步骤的结束很可能发生在所有调用的返回不受其完成阻塞的情况下。

A barrier is a thread coordination mechanism that allows at most an expected count of threads to block until that count is summed (exactly) by threads that arrived at the barrier in each of its successive phases. Once threads are released from blocking at the synchronization point for a phase, they can reuse the same barrier immediately in its next phase. [ Note: It is thus useful for managing repeated tasks, or phases of a larger task, that are handled by multiple threads. — end note ]
A barrier has a completion step that is a (possibly empty) set of effects associated with a phase of the barrier. When the member functions defined in this subclause arrive at the barrier, they have the following effects:
When the expected number of threads for this phase have arrived at the barrier, one of those threads executes the barrier type’s completion step.

When the completion step is completed, all threads blocked at the synchronization point for this phase are unblocked and the barrier enters its next phase. The end of the completion step strongly happens before the returns from all calls unblocked by its completion.

barrier的可能定义

namespace std {template<class CompletionFunction>class barrier {public:using arrival_token = implementation-defined;explicit barrier(ptrdiff_t expected,CompletionFunction f = CompletionFunction());~barrier();barrier(const barrier&) = delete;barrier(barrier&&) = delete;barrier& operator=(const barrier&) = delete;barrier& operator=(barrier&&) = delete;[[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);void wait(arrival_token&& arrival) const;void sync();void arrive_and_drop();private:CompletionFunction completion; // exposition only};
}

  1. semaphores、latch、barrier ↩︎

C++20 barrier相关推荐

  1. iOS中的动力学:Dynamics【1】

    iOS7建议我们创建的界面具有物理特性,而不只是像素的集合,可以响应触摸.手势.屏幕方向改变等事件,让用户与界面之间有更深入的交互,而不是像iOS6那样在软件界面上模仿现实世界的纹理而已.或许你会认为 ...

  2. UIKit 力学教程

    你可能已经注意到 iOS 7 中似乎有一些自相矛盾的地方,苹果在建议放弃真实世界的隐喻和拟物化同时,又鼓励创造体验真实的用户界面. 在实践中这意味着什么呢?iOS 7 的设计目标是鼓励创造能像真实的物 ...

  3. (转载)UIKIt力学教程

    转载自:http://www.cocoachina.com/ios/20131226/7614.html 这篇文章还可以在这里找到 英语, Ray:这篇教程节选自 iOS 7 教程集,它是 iOS 7 ...

  4. Swift中的UIKit重力学(一)

    重力学这个名词不论在哪个行业领域听起来似乎都很高大上.那么在Swift中的重力学是什么呢?那就是将我们移动端屏幕上毫无生命力的东西也置于万有引力中,使它们能够展现出好像真的由于引力而向下坠落以及碰到物 ...

  5. android将vendor挂载为读写,挂载android只读文件系统为可读写

    这个是海思的盒子: root@android:/ # ls -al drwxr-xr-x root     root              1970-01-01 08:00 acct drwxrw ...

  6. 6.CUDA编程手册中文版---附录AB

    附录A 支持GPU设备列表 更多精彩内容,请扫描下方二维码或者访问https://developer.nvidia.com/zh-cn/developer-program 来加入NVIDIA开发者计划 ...

  7. 利用php屏蔽海外ip访问,高效实现

    <?php/*** 屏蔽海外ip访问* 使用ip2long函数得到ip转为整数的值,判断值是否在任一一个区间中* 以下是所有国内ip段* 调用方法:IschinaIp($ALLIPS)* 返回值 ...

  8. 【Linux 内核 内存管理】优化内存屏障 ① ( barrier 优化屏障 | 编译器优化 | CPU 执行优化 | 优化屏障源码 barrier 宏 )

    文章目录 一.优化屏障 ( 编译器优化 | CPU 执行优化 ) 二.优化屏障源码 一.优化屏障 ( 编译器优化 | CPU 执行优化 ) " 代码 " 编译成 " 可执 ...

  9. 护肤产生共鸣_通过以人为本的设计编织共鸣的20个指针

    护肤产生共鸣 Deep into a project right now, I can't help but reflect on how I practice empathy in design. ...

最新文章

  1. 趣谈网络协议笔记-二(第五讲)
  2. acwing2041. 干草堆(差分数组)
  3. 【机器学习】feature_importances_ 参数源码解析
  4. Kafka中副本机制的设计和原理
  5. win8f8修复计算机,Win8怎么在启动时按F8出现修复计算机选项
  6. 在centos7上设置swap交换空间
  7. 关于大量数据的随机打乱重保存.(少了详细解释,之后会更新)
  8. java 正则 工具类_正则表达式工具类,正则表达式封装,Java正则表达式
  9. 在苹果Mac上如何指定发送邮件的时间?
  10. 好莱坞法则_人工智能去好莱坞
  11. 纪录篇 之 我收集整理的一些网址(不断更新 ing)
  12. WPF 矢量字体图标
  13. 生成自己的自签名证书
  14. 为什么程序员大多数都会脱发?( ConcurrentHashMap 并发)
  15. 云服务总线CSB:“连”无边界
  16. 品牌对比 蜜雪冰城 VS 喜茶
  17. 2022中国汽车测试及质量监控博览会
  18. 共用体和结构体所占内存大小的计算方法
  19. 回文树/回文自动机 引入
  20. 循环语句(while)

热门文章

  1. python在地图上标注点_怎样用python画地图上的标注线
  2. badge 不显示 badges 不显示(Bootstrap 徽章)问题
  3. 我对2021年前端团队的规划
  4. 报错: Called “net usershare info“ but it failed
  5. 用canvas画一个太极图(八卦图)
  6. Qt界面中如何嵌入网页?
  7. jmeter之取样器(HTTP请求、调试取样器)
  8. Debug的常用命令
  9. c#中利用keybd_event函数+自定义软键盘实现中文输入时的问题
  10. JAVA记录从键盘输入的正数和负数的个数(0结束)