tbb::task_group_context tg;
SomeClass someObject;
tbb:: parallel_for(tbb::blocked_range<size_t>(0, num, grainSize),
someObject,
tbb::simple_partitioner(),
tg);
class SomeClass
{
void operator()(const tbb::blocked_range<size_t>& r) const
{
tg.cancel_group_execution();
//how do i refer to object tg ?
}
I get the following build error: "tg" not declared in this scope.
How is it using the passed in tg variable?
oneTBB supports Exceptions and Cancellation, that means you just have to throw an exception from
SomeClass::operator()and cancellation will be automatic... You may also Cancel without exceptions by just callingtbb::current_context()->cancel_group_execution().