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 TestSchedulerWorkerThreadDelegate | 87 class TestSchedulerWorkerThreadDelegate |
88 : public SchedulerWorkerThread::Delegate { | 88 : public SchedulerWorkerThread::Delegate { |
89 public: | 89 public: |
90 TestSchedulerWorkerThreadDelegate(TaskSchedulerWorkerThreadTest* outer) | 90 TestSchedulerWorkerThreadDelegate(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 { |
gab
2016/04/25 21:00:20
EXPECT_EQ on |worker_thread|? Or at least EXPECT_T
fdoray
2016/04/25 22:34:44
Done.
| |
95 // Without synchronization, OnMainEntry() could be called twice without | 95 // Without synchronization, 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 INSTANTIATE_TEST_CASE_P(OneTaskPerSequence, | 267 INSTANTIATE_TEST_CASE_P(OneTaskPerSequence, |
268 TaskSchedulerWorkerThreadTest, | 268 TaskSchedulerWorkerThreadTest, |
269 ::testing::Values(1)); | 269 ::testing::Values(1)); |
270 INSTANTIATE_TEST_CASE_P(TwoTasksPerSequence, | 270 INSTANTIATE_TEST_CASE_P(TwoTasksPerSequence, |
271 TaskSchedulerWorkerThreadTest, | 271 TaskSchedulerWorkerThreadTest, |
272 ::testing::Values(2)); | 272 ::testing::Values(2)); |
273 | 273 |
274 } // namespace | 274 } // namespace |
275 } // namespace internal | 275 } // namespace internal |
276 } // namespace base | 276 } // namespace base |
OLD | NEW |