user6042013
user6042013

Reputation: 15

How do I reference the instance of tbb::task_group_context which is being passed in through the tbb::parallel_for loop

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?

Upvotes: 0

Views: 97

Answers (1)

lonestarr
lonestarr

Reputation: 11

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 calling tbb::current_context()->cancel_group_execution().

Upvotes: 0

Related Questions