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

Is feeder.add() mutual exclusive?

kenjiown
Beginner
466 Views
Hi,
feeder.add() in theReference document said "Must be called from a call to body.operator() created by parallel_do. Otherwise,the termination semantics of method operator() are undefined.Must be called from a call to body.operator() created by parallel_do. Otherwise,the termination semantics of method operator() are undefined.".
Does it means if we call feeder.add() outside the body.operator() will cause race condtions and we may lose items if race condtions indeed happen? But if we call it inside the body.operator(), such things will not happen because TBB will guarantees feeder.add() is mutual exclusive?
Thank you.
0 Kudos
1 Reply
RafSchietekat
Valued Contributor III
465 Views
My initial impression is that the documentation leaves room for further optimisation by imposing more restrictions on the programmer than currently required (isn't/shouldn't there be more than one feeder?), but even with this reduced responsibility you would already have to know that parallel_do() is not yet winding down (including removal of that feeder, whose longevity is not guaranteed beyond an operator() call), and, even if you can guarantee that, such code may still break with a future version of TBB.
0 Kudos
Reply