| 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_thread.h" | 5 #include "base/task_scheduler/scheduler_worker_thread.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_, | 58 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_, |
| 59 thread_priority); | 59 thread_priority); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SchedulerWorkerThread::ThreadMain() { | 62 void SchedulerWorkerThread::ThreadMain() { |
| 63 delegate_->OnMainEntry(this); | 63 delegate_->OnMainEntry(this); |
| 64 | 64 |
| 65 // A SchedulerWorkerThread starts out sleeping. | 65 // A SchedulerWorkerThread starts out sleeping. |
| 66 wake_up_event_.Wait(); | 66 wake_up_event_.Wait(); |
| 67 | 67 |
| 68 while (!task_tracker_->shutdown_completed() && !ShouldExitForTesting()) { | 68 while (!task_tracker_->ShutdownCompleted() && !ShouldExitForTesting()) { |
| 69 // Get the sequence containing the next task to execute. | 69 // Get the sequence containing the next task to execute. |
| 70 scoped_refptr<Sequence> sequence = delegate_->GetWork(this); | 70 scoped_refptr<Sequence> sequence = delegate_->GetWork(this); |
| 71 | 71 |
| 72 if (!sequence) { | 72 if (!sequence) { |
| 73 TimeDelta sleep_time = delegate_->GetSleepTimeout(); | 73 TimeDelta sleep_time = delegate_->GetSleepTimeout(); |
| 74 if (sleep_time.is_max()) { | 74 if (sleep_time.is_max()) { |
| 75 // Calling TimedWait with TimeDelta::Max is not recommended per | 75 // Calling TimedWait with TimeDelta::Max is not recommended per |
| 76 // http://crbug.com/465948. | 76 // http://crbug.com/465948. |
| 77 wake_up_event_.Wait(); | 77 wake_up_event_.Wait(); |
| 78 } else { | 78 } else { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool SchedulerWorkerThread::ShouldExitForTesting() const { | 105 bool SchedulerWorkerThread::ShouldExitForTesting() const { |
| 106 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); | 106 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); |
| 107 return should_exit_for_testing_; | 107 return should_exit_for_testing_; |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace internal | 110 } // namespace internal |
| 111 } // namespace base | 111 } // namespace base |
| OLD | NEW |