| 461 | } // namespace |
| 462 | |
| 463 | Future<> AsyncTaskScheduler::Make(FnOnce<Status(AsyncTaskScheduler*)> initial_task, |
| 464 | FnOnce<void(const Status&)> abort_callback, |
| 465 | StopToken stop_token) { |
| 466 | util::tracing::Span span; |
| 467 | auto scope = START_SCOPED_SPAN_SV(span, "AsyncTaskScheduler::InitialTask"sv); |
| 468 | auto scheduler = std::make_unique<AsyncTaskSchedulerImpl>(std::move(stop_token), |
| 469 | std::move(abort_callback)); |
| 470 | Status initial_task_st; |
| 471 | // GH-47642: We normally don't catch exceptions in Arrow C++ code, as the error |
| 472 | // reporting model uses the Status object instead. Usually, an uncaught exception |
| 473 | // will simply terminate the process, surfacing the programming error. |
| 474 | // However, an exception thrown from the initial task would result in a much |
| 475 | // harder to diagnose process hang. |
| 476 | try { |
| 477 | initial_task_st = std::move(initial_task)(scheduler.get()); |
| 478 | } catch (const std::exception& e) { |
| 479 | initial_task_st = Status::UnknownError("Initial task threw an exception: ", e.what()); |
| 480 | } catch (...) { |
| 481 | initial_task_st = Status::UnknownError("Initial task threw an unknown exception"); |
| 482 | } |
| 483 | scheduler->OnTaskFinished(std::move(initial_task_st)); |
| 484 | // Keep scheduler alive until finished |
| 485 | return scheduler->OnFinished().Then([scheduler = std::move(scheduler)] {}); |
| 486 | } |
| 487 | |
| 488 | std::shared_ptr<ThrottledAsyncTaskScheduler> ThrottledAsyncTaskScheduler::Make( |
| 489 | AsyncTaskScheduler* target, int max_concurrent_cost, |
nothing calls this directly
no test coverage detected