Why Intel TBB didn't provide conditional variable like boost?
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 thi开发者_开发知识库s case in TBB?
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)
精彩评论