| 115 | } |
| 116 | |
| 117 | void ThreadPool::sync() { |
| 118 | bool no_finished = false; |
| 119 | do { |
| 120 | no_finished = false; |
| 121 | for (uint32_t i = 0; i < m_nr_threads - 1; ++i) { |
| 122 | if (m_workers[i]->work_flag) { |
| 123 | no_finished = true; |
| 124 | break; |
| 125 | } |
| 126 | } |
| 127 | if (no_finished) { |
| 128 | std::this_thread::yield(); |
| 129 | } |
| 130 | } while (no_finished); |
| 131 | } |
| 132 | void ThreadPool::active() { |
| 133 | if (!m_active) { |
| 134 | std::unique_lock<std::mutex> lock(m_mutex); |
no outgoing calls