1.. _use_graph_reset: 2 3Use graph::reset() to Reset a Canceled Graph 4============================================ 5 6 7When a graph execution is canceled either because of an unhandled 8exception or because its task_group_context is canceled explicitly, the 9graph and its nodes may be left in an indeterminate state. For example, 10in the code samples shown in :ref:`cancel_a_graph` the input 2 may be 11left in a buffer. But even beyond remnants in the buffers, there are 12other optimizations performed during the execution of a flow graph that 13can leave its nodes and edges in an indeterminate state. If you want to 14re-execute or restart a graph, you first need to reset the graph: 15 16 17:: 18 19 20 try { 21 g.wait_for_all(); 22 } catch ( int j ) { 23 cout << "Caught " << j << "\n"; 24 // do something to fix the problem 25 g.reset(); 26 f1.try_put(1); 27 f1.try_put(2); 28 g.wait_for_all(); 29 } 30 31