Add is_finished to TBB Processing Pipelines
There is currently no way to reliably tell that a processing is finished (beside checking the available counters). With TBB, the only way is to call g.wait_for_all()
which is a blocking call. Since we don't want to block the main thread, we can add a task to run the flow graph in the background.
void activate() {
task_arena a;
a.enqueue([background_task([this]() {
// Construct graph (from preconstructed Body)
graph g;
function_node< int, int > f( g, 1, []( int i ) -> int {
return spin_for(i);
});
//Activate source
src.activate();
g.wait_for_all();
// Set captured is_finished
this->is_finished = true;
});
}
...
std::atomic_bool is_finished = false;