| 857 | } |
| 858 | |
| 859 | void CompiledTransformation::wait() { |
| 860 | try { |
| 861 | trace_assert(m_pc == m_seq.size(), "mismature end"); |
| 862 | } catch (...) { |
| 863 | } |
| 864 | if (!m_imperative) { |
| 865 | wait_worker(); |
| 866 | } |
| 867 | for (auto&& box : m_boxes) { |
| 868 | box->reset(); |
| 869 | } |
| 870 | m_pc = 0; |
| 871 | std::exception_ptr graph_exc; |
| 872 | std::swap(m_graph_exc, graph_exc); |
| 873 | m_setted_extern.clear(); |
| 874 | if (graph_exc) { |
| 875 | // graph with exception cannot be reused |
| 876 | recompile(); |
| 877 | std::rethrow_exception(graph_exc); |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | void CompiledTransformation::wait_worker() { |
| 882 | mgb_assert(m_executable != nullptr); |