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 18 matching lines...) Expand all Loading... |
29 // PlatformThread::Delegate. | 29 // PlatformThread::Delegate. |
30 void ThreadMain() override { | 30 void ThreadMain() override { |
31 // Set if this thread was detached. | 31 // Set if this thread was detached. |
32 std::unique_ptr<Thread> detached_thread; | 32 std::unique_ptr<Thread> detached_thread; |
33 | 33 |
34 outer_->delegate_->OnMainEntry(outer_); | 34 outer_->delegate_->OnMainEntry(outer_); |
35 | 35 |
36 // A SchedulerWorker starts out waiting for work. | 36 // A SchedulerWorker starts out waiting for work. |
37 WaitForWork(); | 37 WaitForWork(); |
38 | 38 |
39 while (!outer_->task_tracker_->shutdown_completed() && | 39 while (!outer_->task_tracker_->IsShutdownComplete() && |
40 !outer_->ShouldExitForTesting()) { | 40 !outer_->ShouldExitForTesting()) { |
41 DCHECK(outer_); | 41 DCHECK(outer_); |
42 // Get the sequence containing the next task to execute. | 42 // Get the sequence containing the next task to execute. |
43 scoped_refptr<Sequence> sequence = outer_->delegate_->GetWork(outer_); | 43 scoped_refptr<Sequence> sequence = outer_->delegate_->GetWork(outer_); |
44 if (!sequence) { | 44 if (!sequence) { |
45 if (outer_->delegate_->CanDetach(outer_)) { | 45 if (outer_->delegate_->CanDetach(outer_)) { |
46 detached_thread = outer_->Detach(); | 46 detached_thread = outer_->Detach(); |
47 if (detached_thread) { | 47 if (detached_thread) { |
48 DCHECK_EQ(detached_thread.get(), this); | 48 DCHECK_EQ(detached_thread.get(), this); |
49 PlatformThread::Detach(thread_handle_); | 49 PlatformThread::Detach(thread_handle_); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 CreateThread(); | 213 CreateThread(); |
214 } | 214 } |
215 | 215 |
216 bool SchedulerWorker::ShouldExitForTesting() const { | 216 bool SchedulerWorker::ShouldExitForTesting() const { |
217 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); | 217 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); |
218 return should_exit_for_testing_; | 218 return should_exit_for_testing_; |
219 } | 219 } |
220 | 220 |
221 } // namespace internal | 221 } // namespace internal |
222 } // namespace base | 222 } // namespace base |
OLD | NEW |