为什么Intel TBB不提供boost这样的条件变量?

发布于 2024-10-31 15:42:19 字数 93 浏览 0 评论 0原文

就像条件信号机制一样,我希望一个任务等待,直到收到某个信号或某个变量变为真。 Boost lib提供了这种机制,但TBB没有。

这个案例在TBB中如何实现?

Like conditional signal mechanism, I want one task to wait until some signal is received or some variable becomes true.
Boost lib provide this mechanism, but TBB didn't.

How to implement this case in TBB?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明天过后 2024-11-07 15:42:19

您使用的是非常旧的 TBB 吗?

让任务“等待”是 TBB 过去处理不好的问题,但当前的 TBB 新闻 包含这:

ISO C++ 线程类 – 轻薄便携
操作系统线程的包装器。这是一个
ISO C++ 的近似值
200x 级线程(第 30.2 节
http://www.open-std.org /jtc1/sc22/wg21/docs/papers/2008/n2691.pdf)。
现在 TBB 让您选择最好的,
基于任务与基于线程,对于
你的情况。线程通常是
当“工作”是时,比任务更好
等待实际上比计算更多,
例如:

* GUI、I/O 或网络接口线程。
* 需要等待外部事件的线程。
* 以前需要使用本机线程和英特尔® TBB 任务的程序。

即他们承认 TBB 的任务并行性不是万能的灵丹妙药,有时您需要更像“传统”线程模型的 I/O。事实上,如果您查看最新的参考手册你会发现 TBB 现在包含条件变量! (参见第 8.4 节)

Are you using a very old TBB ?

Having tasks "wait" is something TBB hasn't handled well in the past, but the current TBB news contains this:

ISO C++ thread class – A thin portable
wrapper around OS threads. It's a
close approximation of the ISO C++
200x class thread (Section 30.2 of
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2691.pdf).
Now TBB lets you choose which is best,
task-based versus thread-based, for
your situation. Threads are typically
better than tasks when the "work" is
really more waiting than computation,
such as for:

* GUI, I/O or network interface threads.
* Threads that need to wait on external events.
* Programs that previously needed to use both native threads and Intel® TBB tasks.

ie they're admitting TBB's task parallelism isn't a universal panacea and you need something more like the "traditional" threading model sometimes for I/O. And indeed if you check the latest reference manual you'll find TBB does now contain condition variables! (See section 8.4)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文