Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3561)

Unified Diff: base/task_scheduler/scheduler_worker.cc

Issue 2781933003: Change SchedulerWorker::ShouldExit Checks Ordering (Closed)
Patch Set: Fix Comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_worker.cc
diff --git a/base/task_scheduler/scheduler_worker.cc b/base/task_scheduler/scheduler_worker.cc
index ec7ff0e3cc75a7505429e7d1dc18509d8695aefc..4084c527a73c17e6ba4fa80398e792b1c268566b 100644
--- a/base/task_scheduler/scheduler_worker.cc
+++ b/base/task_scheduler/scheduler_worker.cc
@@ -331,8 +331,12 @@ void SchedulerWorker::CreateThreadAssertSynchronized() {
}
bool SchedulerWorker::ShouldExit() {
- return task_tracker_->IsShutdownComplete() ||
- join_called_for_testing_.IsSet() || should_exit_.IsSet();
+ // The ordering of the checks is important below. This SchedulerWorker may be
+ // released and outlive |task_tracker_| in unit tests. However, when the
+ // SchedulerWorker is released, |should_exit_| will be set, so check that
+ // first.
+ return should_exit_.IsSet() || join_called_for_testing_.IsSet() ||
+ task_tracker_->IsShutdownComplete();
}
} // namespace internal
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698