Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Leader/Followers pattern

rainefan
Beginner
443 Views
Hi! Does TBB has implemented the leader/followers thread pool pattern (link to pdf)? Or I can implement it easily using any template from TBB?

Thanks and regards!
0 Kudos
4 Replies
Anton_Pegushin
New Contributor II
443 Views
Quoting - rainefan
Hi! Does TBB has implemented the leader/followers thread pool pattern (link to pdf)? Or I can implement it easily using any template from TBB?

Thanks and regards!
Hello,

no, TBB does not have a leader/followers pattern implemented, and, unfortunately, tasks and I/O do not mix very well. The support for I/O that TBB currently has is a tbb_thread wrapper around native threads API. However tbb_thread is a portable solution and you could implement leader/followers pattern on the side of your application.
0 Kudos
rainefan
Beginner
443 Views
Hello,

no, TBB does not have a leader/followers pattern implemented, and, unfortunately, tasks and I/O do not mix very well. The support for I/O that TBB currently has is a tbb_thread wrapper around native threads API. However tbb_thread is a portable solution and you could implement leader/followers pattern on the side of your application.

Thank you so much for the quick reply.

But does it means that TBB is not indicated (efficient) to process I/O (networking, fo example) ?

Thanks again for any tip!
Regards,
Raine
0 Kudos
Alexey-Kukanov
Employee
443 Views
Quoting - rainefan
But does it means that TBB is not indicated (efficient) to process I/O (networking, fo example) ?

TBB tasks are executed by threads. If a task has a blocking I/O call, it will block the thread executing it, leading to CPU under-utilization despite other tasks available for execution. In some cases, due to some TBB task scheduler implementation details, it may lead to progress being blocked for task trees that donot directly depend on the task waiting for I/O. In some cases, it may lead to idle-spinning of other threads. So basically TBB tasks may use I/O, though with the price of possible suboptimal work.
0 Kudos
Alexey-Kukanov
Employee
443 Views
Quoting - rainefan
Hi! Does TBB has implemented the leader/followers thread pool pattern (link to pdf)? Or I can implement it easily using any template from TBB?

Thanks and regards!

In my opinion, TBB pipeline more or less fits the pattern for what they call "unbound thread-handle association". For the case where an event should be processed by a particular thread that earlier took care of its predecessor, there is no ready solution.
0 Kudos
Reply