I'm working with TBB for the first time and want to run a sequence of tasks that are all independent. I wanted to use tbb::task::enqueue, i.e. I create a root task and it creates a child task that is independent of the parent. This child can create a task again and so on.
My solution does not work, because the child task calls the parent again and I get an endless cascade. The execution of the root task works, but as soon as a child is created, there is an endless cascade.
// initialization
tbb::task::enqueue( *new( tbb::task::allocate_root() ) tbbwrapper::ctask( <some data> ) );
// execute method
tbb::task* ctask::execute()
{
<execute data processing>
return <data result correct>
? new( this->allocate_child() ) tbbwrapper::ctask( <result data> )
: NULL;
}
I have a lot of tasks (all are independent and the execution order is also completely independent) to run and each task can create a successor, but it is completely undependent and just needs to be added to the queue to run. Also I don't need Wait or similar, because the execution should run in the background.
I just need a simple example to show me how this works.
task::enqueueare scheduled via a shared work queue, not via work stealing. - Alexey Kukanov