| 338 | |
| 339 | private: |
| 340 | bool SubmitTask(std::unique_ptr<Task> task, int latched_cost, bool in_continue) { |
| 341 | // Wrap the task with a wrapper that runs it and then checks to see if there are any |
| 342 | // queued tasks |
| 343 | std::string_view name = task->name(); |
| 344 | return target_->AddSimpleTask( |
| 345 | [latched_cost, in_continue, inner_task = std::move(task), |
| 346 | self = shared_from_this()]() mutable -> Result<Future<>> { |
| 347 | ARROW_ASSIGN_OR_RAISE(Future<> inner_fut, (*inner_task)()); |
| 348 | if (!inner_fut.TryAddCallback([&] { |
| 349 | return [latched_cost, |
| 350 | weak_self = self->weak_from_this()](const Status& st) -> void { |
| 351 | if (auto self = weak_self.lock(); self && st.ok()) { |
| 352 | self->throttle_->Release(latched_cost); |
| 353 | self->ContinueTasks(); |
| 354 | } |
| 355 | }; |
| 356 | })) { |
| 357 | // If the task is already finished then don't run ContinueTasks |
| 358 | // if we are already running it so we can avoid stack overflow |
| 359 | self->throttle_->Release(latched_cost); |
| 360 | inner_task.reset(); |
| 361 | if (!in_continue) { |
| 362 | self->ContinueTasks(); |
| 363 | } |
| 364 | } |
| 365 | return inner_fut; |
| 366 | }, |
| 367 | name); |
| 368 | } |
| 369 | |
| 370 | void ContinueTasks() { |
| 371 | std::unique_lock lk(mutex_); |
nothing calls this directly
no test coverage detected