Skip to content

Commit 2a93845

Browse files
author
Rafał Hibner
committed
running_tasks_mutex_
1 parent aaee634 commit 2a93845

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cpp/src/arrow/util/async_util.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,17 @@ class AsyncTaskSchedulerImpl : public AsyncTaskScheduler {
211211
// OnTaskFinished might trigger the scheduler to end. We want to ensure that
212212
// is the very last thing that happens after all task destructors have run so
213213
// we eagerly destroy the task first.
214-
running_tasks_set_.erase(task_inner2.get());
214+
{
215+
std::unique_lock<std::mutex> lk(running_tasks_mutex_);
216+
running_tasks_set_.erase(task_inner2.get());
217+
}
215218
task_inner2.reset();
216219
OnTaskFinished(st);
217220
};
218221
})) {
219222
return OnTaskFinished(submit_result->status());
220223
} else {
224+
std::unique_lock<std::mutex> lk(running_tasks_mutex_);
221225
running_tasks_set_.insert(task_ptr);
222226
}
223227
}
@@ -271,6 +275,7 @@ class AsyncTaskSchedulerImpl : public AsyncTaskScheduler {
271275
return DoSubmitTask(std::move(task));
272276
}
273277

278+
std::mutex running_tasks_mutex_;
274279
std::unordered_set<Task*> running_tasks_set_;
275280
Future<> finished_ = Future<>::Make();
276281
// The initial task is our first task

0 commit comments

Comments
 (0)