Is feeder.add() mutual exclusive?

Is feeder.add() mutual exclusive?

kenjiown's picture

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.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Raf Schietekat's picture

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.

Login to leave a comment.