in source/static_thread_pool.cpp [53:77]
void context::run(std::uint32_t index) noexcept {
while (true) {
task_base* task = nullptr;
for (std::uint32_t i = 0; i < threadCount_; ++i) {
auto queueIndex = (index + i) < threadCount_
? (index + i)
: (index + i - threadCount_);
auto& state = threadStates_[queueIndex];
task = state.try_pop();
if (task != nullptr) {
break;
}
}
if (task == nullptr) {
task = threadStates_[index].pop();
if (task == nullptr) {
// request_stop() was called.
return;
}
}
task->execute(task);
}
}