| 171 | /// class Coordinator |
| 172 | |
| 173 | Coordinator::~Coordinator() |
| 174 | { |
| 175 | MutexLockGuard guard(m_mutex, FB_FUNCTION); |
| 176 | |
| 177 | for (WorkerThread** p = m_activeThreads.begin(); p < m_activeThreads.end(); p++) |
| 178 | (*p)->shutdown(false); |
| 179 | |
| 180 | while (!m_activeThreads.isEmpty()) |
| 181 | { |
| 182 | WorkerThread* thd = m_activeThreads.pop(); |
| 183 | { |
| 184 | MutexUnlockGuard unlock(m_mutex, FB_FUNCTION); |
| 185 | thd->shutdown(true); |
| 186 | } |
| 187 | delete thd; |
| 188 | } |
| 189 | |
| 190 | while (!m_idleThreads.isEmpty()) |
| 191 | { |
| 192 | WorkerThread* thd = m_idleThreads.pop(); |
| 193 | { |
| 194 | MutexUnlockGuard unlock(m_mutex, FB_FUNCTION); |
| 195 | thd->shutdown(true); |
| 196 | } |
| 197 | delete thd; |
| 198 | } |
| 199 | |
| 200 | while (!m_activeWorkers.isEmpty()) |
| 201 | { |
| 202 | Worker* w = m_activeWorkers.back(); |
| 203 | |
| 204 | MutexUnlockGuard unlock(m_mutex, FB_FUNCTION); |
| 205 | w->waitFor(-1); |
| 206 | } |
| 207 | |
| 208 | while (!m_idleWorkers.isEmpty()) |
| 209 | { |
| 210 | Worker* w = m_idleWorkers.pop(); |
| 211 | delete w; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | void Coordinator::runSync(Task* task) |
| 216 | { |