File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments