| 120 | } |
| 121 | |
| 122 | void NormalExecEnv::start_exec() { |
| 123 | #if MGB_HAVE_THREAD |
| 124 | resume_exec(); |
| 125 | #endif |
| 126 | |
| 127 | if (m_async_level) { |
| 128 | mgb_assert(!m_worker_task_queue.empty()); |
| 129 | if (m_worker_task_queue.size() > 1 || (m_async_level & 0b100)) { |
| 130 | if (m_worker_set.empty()) { |
| 131 | // init async dispatch workers |
| 132 | for (auto&& i : m_worker_task_queue) { |
| 133 | auto runner = [this, cn = i.first]() { |
| 134 | run_task_seq<true>(m_worker_task_queue.at(cn)); |
| 135 | }; |
| 136 | m_worker_set.add_worker( |
| 137 | "comp_node_dispatch:" + i.first.to_string(), runner); |
| 138 | } |
| 139 | } |
| 140 | m_worker_set.start(); |
| 141 | } else { |
| 142 | run_task_seq<false>(m_worker_task_queue.begin()->second); |
| 143 | } |
| 144 | } else { |
| 145 | run_task_seq<false>(m_sync_task_queue); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | void NormalExecEnv::wait_all() { |
| 150 | if (!m_worker_task_queue.empty()) { |