【问题标题】:How to wait for a single task in Intel TBB in a task group and kill others?如何在任务组中等待英特尔 TBB 中的单个任务并杀死其他人?
【发布时间】:2017-11-27 14:53:01
【问题描述】:

在英特尔 TBB 中,我正在尝试: 1.创建一组任务 2.让他们跑 3.当其中一个完成时,我从中得到一些结果并杀死其他人。

我该怎么做?我可以看到只有 API 等待所有而不仅仅是单个...

谢谢。

【问题讨论】:

    标签: c++ task wait intel tbb


    【解决方案1】:

    完成的任务可以将其结果存储在一个已知的地方,并用task::self().cancel_group_execution() 取消组。然后wait_for_all() 将被解除阻塞,并且该线程可以从已知位置加载结果。
    https://www.threadingbuildingblocks.org/docs/help/tbb_userguide/Cancellation_Without_An_Exception.html 显示如何使用cancel_group_execution()

    【讨论】:

      猜你喜欢
      • 2014-02-07
      • 2018-11-25
      • 1970-01-01
      • 2019-05-19
      • 2013-05-26
      • 2019-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多