| 68 | } |
| 69 | |
| 70 | void WorkerPool::stop() { |
| 71 | MutexLocker threadLock(m_threadMutex); |
| 72 | for (auto const& workerThread : m_workerThreads) |
| 73 | workerThread->shouldStop = true; |
| 74 | |
| 75 | { |
| 76 | // Must hold the work lock while broadcasting to ensure that any worker |
| 77 | // threads that might wait without stopping actually get the signal. |
| 78 | MutexLocker workLock(m_workMutex); |
| 79 | m_workCondition.broadcast(); |
| 80 | } |
| 81 | |
| 82 | m_workerThreads.clear(); |
| 83 | } |
| 84 | |
| 85 | void WorkerPool::finish() { |
| 86 | // This is kind of a weird way to "wait" until all the pending work is |