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

Method DoSubmitTask

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

Source from the content-addressed store, hash-verified

194 }
195
196 void DoSubmitTask(std::unique_ptr<Task> task) {
197 Result<Future<>> submit_result = (*task)();
198 if (!submit_result.ok()) {
199 std::unique_lock<std::mutex> lk(mutex_);
200 running_tasks_--;
201 AbortUnlocked(submit_result.status(), std::move(lk));
202 return;
203 }
204 // Capture `task` to keep it alive until finished
205 if (!submit_result->TryAddCallback([this, task_inner = std::move(task)]() mutable {
206 return [this, task_inner2 = std::move(task_inner)](const Status& st) mutable {
207#ifdef ARROW_WITH_OPENTELEMETRY
208 TraceTaskFinished(task_inner2.get());
209#endif
210 // OnTaskFinished might trigger the scheduler to end. We want to ensure that
211 // is the very last thing that happens after all task destructors have run so
212 // we eagerly destroy the task first.
213 task_inner2.reset();
214 OnTaskFinished(st);
215 };
216 })) {
217 return OnTaskFinished(submit_result->status());
218 }
219 }
220
221 void MaybeEndUnlocked(std::unique_lock<std::mutex>&& lk) {
222 if (IsFullyFinished()) {

Callers

nothing calls this directly

Calls 6

TraceTaskFinishedFunction · 0.85
okMethod · 0.45
statusMethod · 0.45
TryAddCallbackMethod · 0.45
getMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected