Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: base/task_scheduler/task_scheduler_impl_unittest.cc

Issue 2501763002: Add Thread Standby Policy SchedulerWorkerPoolImpl (Closed)
Patch Set: Rebase to edc7bea Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 : FOREGROUND_WORKER_POOL; 178 : FOREGROUND_WORKER_POOL;
179 } 179 }
180 180
181 class TaskSchedulerImplTest 181 class TaskSchedulerImplTest
182 : public testing::TestWithParam<TraitsExecutionModePair> { 182 : public testing::TestWithParam<TraitsExecutionModePair> {
183 protected: 183 protected:
184 TaskSchedulerImplTest() = default; 184 TaskSchedulerImplTest() = default;
185 185
186 void SetUp() override { 186 void SetUp() override {
187 using IORestriction = SchedulerWorkerPoolParams::IORestriction; 187 using IORestriction = SchedulerWorkerPoolParams::IORestriction;
188 using StandbyThreadPolicy = SchedulerWorkerPoolParams::StandbyThreadPolicy;
188 189
189 std::vector<SchedulerWorkerPoolParams> params_vector; 190 std::vector<SchedulerWorkerPoolParams> params_vector;
190 191
191 ASSERT_EQ(BACKGROUND_WORKER_POOL, params_vector.size()); 192 ASSERT_EQ(BACKGROUND_WORKER_POOL, params_vector.size());
192 params_vector.emplace_back("Background", ThreadPriority::BACKGROUND, 193 params_vector.emplace_back("Background", ThreadPriority::BACKGROUND,
193 IORestriction::DISALLOWED, 1U, TimeDelta::Max()); 194 IORestriction::DISALLOWED,
195 StandbyThreadPolicy::LAZY, 1U, TimeDelta::Max());
194 196
195 ASSERT_EQ(BACKGROUND_FILE_IO_WORKER_POOL, params_vector.size()); 197 ASSERT_EQ(BACKGROUND_FILE_IO_WORKER_POOL, params_vector.size());
196 params_vector.emplace_back("BackgroundFileIO", ThreadPriority::BACKGROUND, 198 params_vector.emplace_back("BackgroundFileIO", ThreadPriority::BACKGROUND,
197 IORestriction::ALLOWED, 3U, TimeDelta::Max()); 199 IORestriction::ALLOWED,
200 StandbyThreadPolicy::LAZY, 3U, TimeDelta::Max());
198 201
199 ASSERT_EQ(FOREGROUND_WORKER_POOL, params_vector.size()); 202 ASSERT_EQ(FOREGROUND_WORKER_POOL, params_vector.size());
200 params_vector.emplace_back("Foreground", ThreadPriority::NORMAL, 203 params_vector.emplace_back("Foreground", ThreadPriority::NORMAL,
201 IORestriction::DISALLOWED, 4U, TimeDelta::Max()); 204 IORestriction::DISALLOWED,
205 StandbyThreadPolicy::LAZY, 4U, TimeDelta::Max());
202 206
203 ASSERT_EQ(FOREGROUND_FILE_IO_WORKER_POOL, params_vector.size()); 207 ASSERT_EQ(FOREGROUND_FILE_IO_WORKER_POOL, params_vector.size());
204 params_vector.emplace_back("ForegroundFileIO", ThreadPriority::NORMAL, 208 params_vector.emplace_back(
205 IORestriction::ALLOWED, 12U, TimeDelta::Max()); 209 "ForegroundFileIO", ThreadPriority::NORMAL, IORestriction::ALLOWED,
210 StandbyThreadPolicy::LAZY, 12U, TimeDelta::Max());
206 211
207 scheduler_ = TaskSchedulerImpl::Create(params_vector, 212 scheduler_ = TaskSchedulerImpl::Create(params_vector,
208 Bind(&GetThreadPoolIndexForTraits)); 213 Bind(&GetThreadPoolIndexForTraits));
209 ASSERT_TRUE(scheduler_); 214 ASSERT_TRUE(scheduler_);
210 } 215 }
211 216
212 void TearDown() override { scheduler_->JoinForTesting(); } 217 void TearDown() override { scheduler_->JoinForTesting(); }
213 218
214 std::unique_ptr<TaskSchedulerImpl> scheduler_; 219 std::unique_ptr<TaskSchedulerImpl> scheduler_;
215 220
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 thread->WaitForAllTasksToRun(); 277 thread->WaitForAllTasksToRun();
273 thread->Join(); 278 thread->Join();
274 } 279 }
275 } 280 }
276 281
277 // TODO(fdoray): Add tests with Sequences that move around worker pools once 282 // TODO(fdoray): Add tests with Sequences that move around worker pools once
278 // child TaskRunners are supported. 283 // child TaskRunners are supported.
279 284
280 } // namespace internal 285 } // namespace internal
281 } // namespace base 286 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_params.cc ('k') | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698