Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dmitry_Dobryak
Beginner
71 Views

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);

0 Kudos
2 Replies
Dmitry_Dobryak
Beginner
71 Views

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?
RafSchietekat
Black Belt
71 Views

"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.
Reply