Say, there is a master thread that deploys TBB to spawn additional worker threads, as shown in the code snippet below.
The master thread continues with its business, without waiting for arena group to finish. However, the master thread may happen to finish well before the worker threads.
So the logical question is: would it be possible to implement late-join of master thread to the arena group and use its clocks to help out with the remaining work? Any equivalent TBB-based solution to achieve this scenario?
tbb::task_group group;
tbb::task_arena arena(nthreads, 1);
tbb::task_scheduler_init init(nthreads);
arena.enqueue( [&]
{
group.run( [&]
{
...
});
});
// Work done on master thread here
// Master thread has finished: can it now join the arena group
// and help with the remaining work?
group.wait();