MCPcopy Create free account
hub / github.com/apache/arrow / SubmitTask

Method SubmitTask

cpp/src/arrow/util/async_util.cc:341–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

ContinueTasksMethod · 0.95
nameMethod · 0.45
TryAddCallbackMethod · 0.45
okMethod · 0.45
ReleaseMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected