gpt4 book ai didi

multithreading - 为什么英特尔TBB不提供Boost等条件变量?

转载 作者:行者123 更新时间:2023-12-03 12:52:59 25 4
gpt4 key购买 nike

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

如何在TBB中实现这种情况?

最佳答案

您使用的是旧的TBB吗?

任务“等待”是TBB过去无法很好地处理的,但是当前的TBB news包含以下内容:

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.


也就是说,他们承认TBB的任务并行性不是通用的 Elixir ,并且有时您需要针对I/O的“传统”线程模型。实际上,如果您检查最新的 reference manual,您会发现TBB现在包含条件变量! (请参阅第8.4节)

关于multithreading - 为什么英特尔TBB不提供Boost等条件变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5636148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com