| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/task_scheduler/scheduler_worker.h" | 5 #include "base/task_scheduler/scheduler_worker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void SchedulerWorker::CreateThread() { | 324 void SchedulerWorker::CreateThread() { |
| 325 thread_ = Thread::Create(make_scoped_refptr(this)); | 325 thread_ = Thread::Create(make_scoped_refptr(this)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void SchedulerWorker::CreateThreadAssertSynchronized() { | 328 void SchedulerWorker::CreateThreadAssertSynchronized() { |
| 329 thread_lock_.AssertAcquired(); | 329 thread_lock_.AssertAcquired(); |
| 330 CreateThread(); | 330 CreateThread(); |
| 331 } | 331 } |
| 332 | 332 |
| 333 bool SchedulerWorker::ShouldExit() { | 333 bool SchedulerWorker::ShouldExit() { |
| 334 return task_tracker_->IsShutdownComplete() || | 334 // The ordering of the checks is important below. This SchedulerWorker may be |
| 335 join_called_for_testing_.IsSet() || should_exit_.IsSet(); | 335 // released and outlive |task_tracker_| in unit tests. However, when the |
| 336 // SchedulerWorker is released, |should_exit_| will be set, so check that |
| 337 // first. |
| 338 return should_exit_.IsSet() || join_called_for_testing_.IsSet() || |
| 339 task_tracker_->IsShutdownComplete(); |
| 336 } | 340 } |
| 337 | 341 |
| 338 } // namespace internal | 342 } // namespace internal |
| 339 } // namespace base | 343 } // namespace base |
| OLD | NEW |