ARROW_ENABLE_THREADING
| 293 | } |
| 294 | #else // ARROW_ENABLE_THREADING |
| 295 | bool SerialExecutor::RunTasksOnAllExecutors() { |
| 296 | auto globalState = GetSerialExecutorGlobalState(); |
| 297 | // if the previously called executor was deleted, ignore last_called_executor |
| 298 | if (globalState->last_called_executor != NULL && |
| 299 | globalState->all_executors.count(globalState->last_called_executor) == 0) { |
| 300 | globalState->last_called_executor = NULL; |
| 301 | } |
| 302 | bool run_task = true; |
| 303 | bool keep_going = true; |
| 304 | while (keep_going) { |
| 305 | run_task = false; |
| 306 | keep_going = false; |
| 307 | for (auto it = globalState->all_executors.begin(); |
| 308 | it != globalState->all_executors.end(); ++it) { |
| 309 | if (globalState->last_called_executor != NULL) { |
| 310 | // always rerun loop if we have a last_called_executor, otherwise |
| 311 | // we may drop out before every executor has been checked |
| 312 | keep_going = true; |
| 313 | if (globalState->all_executors.count(globalState->last_called_executor) == 0 || |
| 314 | globalState->last_called_executor == *it) { |
| 315 | // found the last one (or it doesn't exist ih the set any more) |
| 316 | // now we can start running things |
| 317 | globalState->last_called_executor = NULL; |
| 318 | } |
| 319 | // skip until after we have seen the last executor we called |
| 320 | // so that we do things nicely in turn |
| 321 | continue; |
| 322 | } |
| 323 | auto exe = *it; |
| 324 | // don't make more reentrant calls inside an |
| 325 | // executor than the number of concurrent tasks set on a threadpool, or |
| 326 | // 1 in the case of a serialexecutor - |
| 327 | // this is because users will expect a serial executor not to be able to |
| 328 | // run the next task until the current one is finished (and a threadpool |
| 329 | // only to be able to run a certain number of tasks concurrently) |
| 330 | if (exe->state_->tasks_running >= exe->state_->max_tasks_running) { |
| 331 | continue; |
| 332 | } |
| 333 | if (exe->state_->paused == false && exe->state_->task_queue.empty() == false) { |
| 334 | SerialExecutor* old_exe = globalState->current_executor; |
| 335 | globalState->current_executor = exe; |
| 336 | Task task = std::move(const_cast<Task&>(exe->state_->task_queue.top().task)); |
| 337 | exe->state_->task_queue.pop(); |
| 338 | run_task = true; |
| 339 | exe->state_->tasks_running += 1; |
| 340 | if (!task.stop_token.IsStopRequested()) { |
| 341 | std::move(task.callable)(); |
| 342 | } else { |
| 343 | if (task.stop_callback) { |
| 344 | std::move(task.stop_callback)(task.stop_token.Poll()); |
| 345 | } |
| 346 | } |
| 347 | exe->state_->tasks_running -= 1; |
| 348 | globalState->current_executor = old_exe; |
| 349 | |
| 350 | globalState->last_called_executor = exe; |
| 351 | keep_going = false; |
| 352 | break; |
nothing calls this directly
no test coverage detected