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 <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 std::unique_ptr<SchedulerWorkerThread> worker_thread_; | 84 std::unique_ptr<SchedulerWorkerThread> worker_thread_; |
85 | 85 |
86 private: | 86 private: |
87 class SchedulerWorkerThreadDelegateImpl | 87 class SchedulerWorkerThreadDelegateImpl |
88 : public SchedulerWorkerThread::Delegate { | 88 : public SchedulerWorkerThread::Delegate { |
89 public: | 89 public: |
90 SchedulerWorkerThreadDelegateImpl(TaskSchedulerWorkerThreadTest* outer) | 90 SchedulerWorkerThreadDelegateImpl(TaskSchedulerWorkerThreadTest* outer) |
91 : outer_(outer) {} | 91 : outer_(outer) {} |
92 | 92 |
93 // SchedulerWorkerThread::Delegate: | 93 // SchedulerWorkerThread::Delegate: |
94 void OnMainEntry() override { | 94 void OnMainEntry(SchedulerWorkerThread* worker_thread) override { |
95 // Without this |auto_lock|, OnMainEntry() could be called twice without | 95 // Without this |auto_lock|, OnMainEntry() could be called twice without |
96 // generating an error. | 96 // generating an error. |
97 AutoSchedulerLock auto_lock(outer_->lock_); | 97 AutoSchedulerLock auto_lock(outer_->lock_); |
98 EXPECT_FALSE(outer_->main_entry_called_.IsSignaled()); | 98 EXPECT_FALSE(outer_->main_entry_called_.IsSignaled()); |
99 outer_->main_entry_called_.Signal(); | 99 outer_->main_entry_called_.Signal(); |
100 } | 100 } |
101 | 101 |
102 scoped_refptr<Sequence> GetWork( | 102 scoped_refptr<Sequence> GetWork( |
103 SchedulerWorkerThread* worker_thread) override { | 103 SchedulerWorkerThread* worker_thread) override { |
104 EXPECT_EQ(outer_->worker_thread_.get(), worker_thread); | 104 EXPECT_EQ(outer_->worker_thread_.get(), worker_thread); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 INSTANTIATE_TEST_CASE_P(OneTaskPerSequence, | 268 INSTANTIATE_TEST_CASE_P(OneTaskPerSequence, |
269 TaskSchedulerWorkerThreadTest, | 269 TaskSchedulerWorkerThreadTest, |
270 ::testing::Values(1)); | 270 ::testing::Values(1)); |
271 INSTANTIATE_TEST_CASE_P(TwoTasksPerSequence, | 271 INSTANTIATE_TEST_CASE_P(TwoTasksPerSequence, |
272 TaskSchedulerWorkerThreadTest, | 272 TaskSchedulerWorkerThreadTest, |
273 ::testing::Values(2)); | 273 ::testing::Values(2)); |
274 | 274 |
275 } // namespace | 275 } // namespace |
276 } // namespace internal | 276 } // namespace internal |
277 } // namespace base | 277 } // namespace base |
OLD | NEW |