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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 task_tracker_(task_tracker) { | 52 task_tracker_(task_tracker) { |
53 DCHECK(delegate_); | 53 DCHECK(delegate_); |
54 DCHECK(task_tracker_); | 54 DCHECK(task_tracker_); |
55 | 55 |
56 const size_t kDefaultStackSize = 0; | 56 const size_t kDefaultStackSize = 0; |
57 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_, | 57 PlatformThread::CreateWithPriority(kDefaultStackSize, this, &thread_handle_, |
58 thread_priority); | 58 thread_priority); |
59 } | 59 } |
60 | 60 |
61 void SchedulerWorkerThread::ThreadMain() { | 61 void SchedulerWorkerThread::ThreadMain() { |
62 delegate_->OnMainEntry(); | 62 delegate_->OnMainEntry(this); |
63 | 63 |
64 // A SchedulerWorkerThread starts out sleeping. | 64 // A SchedulerWorkerThread starts out sleeping. |
65 wake_up_event_.Wait(); | 65 wake_up_event_.Wait(); |
66 | 66 |
67 while (!task_tracker_->shutdown_completed() && !ShouldExitForTesting()) { | 67 while (!task_tracker_->shutdown_completed() && !ShouldExitForTesting()) { |
68 // Get the sequence containing the next task to execute. | 68 // Get the sequence containing the next task to execute. |
69 scoped_refptr<Sequence> sequence = delegate_->GetWork(this); | 69 scoped_refptr<Sequence> sequence = delegate_->GetWork(this); |
70 | 70 |
71 if (!sequence) { | 71 if (!sequence) { |
72 wake_up_event_.Wait(); | 72 wake_up_event_.Wait(); |
(...skipping 21 matching lines...) Expand all Loading... |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 bool SchedulerWorkerThread::ShouldExitForTesting() const { | 97 bool SchedulerWorkerThread::ShouldExitForTesting() const { |
98 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); | 98 AutoSchedulerLock auto_lock(should_exit_for_testing_lock_); |
99 return should_exit_for_testing_; | 99 return should_exit_for_testing_; |
100 } | 100 } |
101 | 101 |
102 } // namespace internal | 102 } // namespace internal |
103 } // namespace base | 103 } // namespace base |
OLD | NEW |