OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/sequenced_worker_pool.h" | 5 #include "base/threading/sequenced_worker_pool.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 pool()->Shutdown(); | 984 pool()->Shutdown(); |
985 } | 985 } |
986 | 986 |
987 // Verify that FlushForTesting works as intended. | 987 // Verify that FlushForTesting works as intended. |
988 TEST_P(SequencedWorkerPoolTest, FlushForTesting) { | 988 TEST_P(SequencedWorkerPoolTest, FlushForTesting) { |
989 // Should be fine to call on a new instance. | 989 // Should be fine to call on a new instance. |
990 pool()->FlushForTesting(); | 990 pool()->FlushForTesting(); |
991 | 991 |
992 // Queue up a bunch of work, including a long delayed task and | 992 // Queue up a bunch of work, including a long delayed task and |
993 // a task that produces additional tasks as an artifact. | 993 // a task that produces additional tasks as an artifact. |
994 pool()->PostDelayedWorkerTask( | 994 pool()->PostDelayedTask(FROM_HERE, |
995 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 0), | 995 base::BindOnce(&TestTracker::FastTask, tracker(), 0), |
996 TimeDelta::FromMinutes(5)); | 996 TimeDelta::FromMinutes(5)); |
997 pool()->PostWorkerTask(FROM_HERE, | 997 pool()->PostWorkerTask(FROM_HERE, |
998 base::BindOnce(&TestTracker::SlowTask, tracker(), 0)); | 998 base::BindOnce(&TestTracker::SlowTask, tracker(), 0)); |
999 const size_t kNumFastTasks = 20; | 999 const size_t kNumFastTasks = 20; |
1000 for (size_t i = 0; i < kNumFastTasks; i++) { | 1000 for (size_t i = 0; i < kNumFastTasks; i++) { |
1001 pool()->PostWorkerTask( | 1001 pool()->PostWorkerTask( |
1002 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 0)); | 1002 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 0)); |
1003 } | 1003 } |
1004 pool()->PostWorkerTask( | 1004 pool()->PostWorkerTask( |
1005 FROM_HERE, base::BindOnce(&TestTracker::PostAdditionalTasks, tracker(), 0, | 1005 FROM_HERE, base::BindOnce(&TestTracker::PostAdditionalTasks, tracker(), 0, |
1006 base::RetainedRef(pool()), true)); | 1006 base::RetainedRef(pool()), true)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest, | 1223 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest, |
1224 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); | 1224 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); |
1225 INSTANTIATE_TYPED_TEST_CASE_P( | 1225 INSTANTIATE_TYPED_TEST_CASE_P( |
1226 SequencedWorkerPoolSequencedTaskRunner, | 1226 SequencedWorkerPoolSequencedTaskRunner, |
1227 SequencedTaskRunnerDelayedTest, | 1227 SequencedTaskRunnerDelayedTest, |
1228 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); | 1228 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); |
1229 | 1229 |
1230 } // namespace | 1230 } // namespace |
1231 | 1231 |
1232 } // namespace base | 1232 } // namespace base |
OLD | NEW |