| 210 | } |
| 211 | |
| 212 | void TaskScheduler::ThreadPool::thread_loop(size_t globalThreadIndex) |
| 213 | { |
| 214 | while (globalThreadIndex < numThreadsRunning) |
| 215 | { |
| 216 | Ref<TaskScheduler> scheduler = NULL; |
| 217 | ssize_t threadIndex = -1; |
| 218 | { |
| 219 | Lock<MutexSys> lock(mutex); |
| 220 | condition.wait(mutex, [&] () { return globalThreadIndex >= numThreadsRunning || !schedulers.empty(); }); |
| 221 | if (globalThreadIndex >= numThreadsRunning) break; |
| 222 | scheduler = schedulers.front(); |
| 223 | threadIndex = scheduler->allocThreadIndex(); |
| 224 | } |
| 225 | scheduler->thread_loop(threadIndex); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | TaskScheduler::TaskScheduler() |
| 230 | : threadCounter(0), anyTasksRunning(0), hasRootTask(false) |
no test coverage detected