| 55 | WorkerPool& WorkerPool::operator=(WorkerPool&&) = default; |
| 56 | |
| 57 | void WorkerPool::start(unsigned threadCount) { |
| 58 | MutexLocker threadLock(m_threadMutex); |
| 59 | |
| 60 | for (auto const& workerThread : m_workerThreads) |
| 61 | workerThread->shouldStop = true; |
| 62 | |
| 63 | m_workCondition.broadcast(); |
| 64 | m_workerThreads.clear(); |
| 65 | |
| 66 | for (size_t i = m_workerThreads.size(); i < threadCount; ++i) |
| 67 | m_workerThreads.append(make_unique<WorkerThread>(this)); |
| 68 | } |
| 69 | |
| 70 | void WorkerPool::stop() { |
| 71 | MutexLocker threadLock(m_threadMutex); |