I have been using flow_graph for a while and at the exit of my program, there is a wait_for_all() call on the graph. The program hangs there and cannot exit. What can i check in order to find the reason and fix this problem?
actually it is hard to share.
I have just one graph object and several classes use this same graph for their async needs. Corresponding function nodes are called with try_put() methods.
Is there no way to understand the graph's current status, etc. before wait_for_all() call?
There is no such status API for the graph as far as I know.
Ok, then how this async needs is organized? Do you use any native (non TBB thread-pool threads)? What TBB version do you use?
version i use: 4.4~20151115-0ubuntu3
I have 1 long running task and 2 pthreads in addition to the graph usage. In the log, i see that their infinite loops end before wait_for_all(). (pthreads' join calls are after wait_for_all() )
Seems like this is a multiple wait issue. By default, the graph is created with default task_group context, which can lead to root task ref_count races in concurrent wait scenario. Pass appropriate task_group_context to the graph constructor:
tbb::task_group_context ctx( tbb::task_group_context::bound, tbb::task_group_context::concurrent_wait ); tbb::flow::graph g( ctx );
Also, use the latest version of TBB. We have fixed other possible hanging scenarios for the graph there.