Chromium Code Reviews| 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/task_scheduler_impl.h" | 5 #include "base/task_scheduler/task_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 GetParam().execution_mode); | 270 GetParam().execution_mode); |
| 271 EXPECT_FALSE(factory.task_runner()->RunsTasksOnCurrentThread()); | 271 EXPECT_FALSE(factory.task_runner()->RunsTasksOnCurrentThread()); |
| 272 | 272 |
| 273 const size_t kNumTasksPerTest = 150; | 273 const size_t kNumTasksPerTest = 150; |
| 274 for (size_t i = 0; i < kNumTasksPerTest; ++i) { | 274 for (size_t i = 0; i < kNumTasksPerTest; ++i) { |
| 275 factory.PostTask(test::TestTaskFactory::PostNestedTask::NO, | 275 factory.PostTask(test::TestTaskFactory::PostNestedTask::NO, |
| 276 Bind(&VerifyTaskEnvironment, GetParam().traits)); | 276 Bind(&VerifyTaskEnvironment, GetParam().traits)); |
| 277 } | 277 } |
| 278 | 278 |
| 279 factory.WaitForAllTasksToRun(); | 279 factory.WaitForAllTasksToRun(); |
| 280 | |
| 281 // State like Single Thread Task Runners may be lingering around at this point | |
| 282 // attached to tasks on their running thread even though | |
| 283 // WaitForAllTasksToRun() returned. This will cause issues when Single Thread | |
| 284 // Task Runner unregistration occurs during JoinForTesting(). Flushing out the | |
| 285 // tasks prevents this state. | |
| 286 scheduler_->FlushForTesting(); | |
|
fdoray
2017/01/27 16:47:35
Is the issue that this DCHECK can be hit https://c
robliao
2017/01/27 21:25:41
sgtm. Done. Added a reinforcing comment in task_sc
| |
| 280 } | 287 } |
| 281 | 288 |
| 282 INSTANTIATE_TEST_CASE_P(OneTraitsExecutionModePair, | 289 INSTANTIATE_TEST_CASE_P(OneTraitsExecutionModePair, |
| 283 TaskSchedulerImplTest, | 290 TaskSchedulerImplTest, |
| 284 ::testing::ValuesIn(GetTraitsExecutionModePairs())); | 291 ::testing::ValuesIn(GetTraitsExecutionModePairs())); |
| 285 | 292 |
| 286 // Spawns threads that simultaneously post Tasks to TaskRunners with various | 293 // Spawns threads that simultaneously post Tasks to TaskRunners with various |
| 287 // TaskTraits and ExecutionModes. Verifies that each Task runs on a thread with | 294 // TaskTraits and ExecutionModes. Verifies that each Task runs on a thread with |
| 288 // the expected priority and I/O restrictions and respects the characteristics | 295 // the expected priority and I/O restrictions and respects the characteristics |
| 289 // of its ExecutionMode. | 296 // of its ExecutionMode. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 300 thread->WaitForAllTasksToRun(); | 307 thread->WaitForAllTasksToRun(); |
| 301 thread->Join(); | 308 thread->Join(); |
| 302 } | 309 } |
| 303 } | 310 } |
| 304 | 311 |
| 305 // TODO(fdoray): Add tests with Sequences that move around worker pools once | 312 // TODO(fdoray): Add tests with Sequences that move around worker pools once |
| 306 // child TaskRunners are supported. | 313 // child TaskRunners are supported. |
| 307 | 314 |
| 308 } // namespace internal | 315 } // namespace internal |
| 309 } // namespace base | 316 } // namespace base |
| OLD | NEW |