Skip to content

Commit 97ade7e

Browse files
author
Rafał Hibner
committed
Track running tasks
1 parent 7469eca commit 97ade7e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cpp/src/arrow/util/async_util.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class AsyncTaskSchedulerImpl : public AsyncTaskScheduler {
170170
if (IsAborted()) {
171171
return false;
172172
}
173+
running_tasks_set_.insert(task.get());
173174
SubmitTaskUnlocked(std::move(task), std::move(lk));
174175
return true;
175176
}
@@ -210,6 +211,7 @@ class AsyncTaskSchedulerImpl : public AsyncTaskScheduler {
210211
// OnTaskFinished might trigger the scheduler to end. We want to ensure that
211212
// is the very last thing that happens after all task destructors have run so
212213
// we eagerly destroy the task first.
214+
running_tasks_set_.erase(task_inner2.get());
213215
task_inner2.reset();
214216
OnTaskFinished(st);
215217
};
@@ -267,6 +269,7 @@ class AsyncTaskSchedulerImpl : public AsyncTaskScheduler {
267269
return DoSubmitTask(std::move(task));
268270
}
269271

272+
std::unordered_set<Task*> running_tasks_set_;
270273
Future<> finished_ = Future<>::Make();
271274
// The initial task is our first task
272275
int running_tasks_ = 1;

0 commit comments

Comments
 (0)