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