best pattern for long-time working threads

best pattern for long-time working threads

Hi!

My program must have 3 threads which working during whole programs life in parallel. They must communicate each other. What is the best pattern for this? task:enqueue?
Something like this:
LongTask* t = new (tbb::task::allocate_root())LongTask();

LongTask* t1 = new (tbb::task::allocate_root())LongTask();
LongTask* t2 = new (tbb::task::allocate_root())LongTask();
tbb::task:enqueue(*t);
tbb::task:enqueue(*t1);
tbb::task:enqueue(*t2);

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

As I understand boost::thread is more suitable in this case because TBB is not guarantee that tasks will run in parallel. But Is it possible to use boost::thread to create threads and tbb concurent containers, tbb sync primitives for use in that boost threads?

"As I understand boost::thread is more suitable in this case because TBB
is not guarantee that tasks will run in parallel."
Correct.

"But Is it possible to
use boost::thread to create threads and tbb concurent containers, tbb
sync primitives for use in that boost threads?"
Any API to create threads will do (TBB even has its own in anticipation of the latest standard C++ if your compiler does not provide that yet), and you don't even have to make a choice; TBB's other features should work regardless of how the threads were created.

Leave a Comment

Please sign in to add a comment. Not a member? Join today