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

Side by Side Diff: base/test/scoped_async_task_scheduler.cc

Issue 2749303002: [reference - do not submit] Always create four pools in TaskSchedulerImpl. (Closed)
Patch Set: rebase Created 3 years, 9 months 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/test/scoped_async_task_scheduler.h" 5 #include "base/test/scoped_async_task_scheduler.h"
6 6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/logging.h" 7 #include "base/logging.h"
11 #include "base/task_scheduler/scheduler_worker_pool_params.h" 8 #include "base/task_scheduler/scheduler_worker_pool_params.h"
12 #include "base/task_scheduler/task_scheduler.h" 9 #include "base/task_scheduler/task_scheduler.h"
13 #include "base/task_scheduler/task_scheduler_impl.h"
14 10
15 namespace base { 11 namespace base {
16 namespace test { 12 namespace test {
17 13
18 ScopedAsyncTaskScheduler::ScopedAsyncTaskScheduler() { 14 ScopedAsyncTaskScheduler::ScopedAsyncTaskScheduler() {
19 DCHECK(!TaskScheduler::GetInstance()); 15 DCHECK(!TaskScheduler::GetInstance());
20 constexpr int kMaxThreads = 1; 16 constexpr int kMaxThreads = 1;
21 const TimeDelta kSuggestedReclaimTime = TimeDelta::Max(); 17 const TimeDelta kSuggestedReclaimTime = TimeDelta::Max();
22 std::vector<SchedulerWorkerPoolParams> worker_pool_params_vector; 18 const SchedulerWorkerPoolParams worker_pool_params{
23 worker_pool_params_vector.emplace_back(
24 "ScopedAsyncTaskScheduler", ThreadPriority::NORMAL,
25 SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY, kMaxThreads, 19 SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY, kMaxThreads,
26 kSuggestedReclaimTime); 20 kSuggestedReclaimTime};
27 TaskScheduler::CreateAndSetDefaultTaskScheduler( 21 TaskScheduler::CreateAndSetDefaultTaskScheduler(
28 worker_pool_params_vector, 22 "ScopedAsync", {worker_pool_params, worker_pool_params,
29 Bind([](const TaskTraits&) -> size_t { return 0; })); 23 worker_pool_params, worker_pool_params});
30 task_scheduler_ = TaskScheduler::GetInstance(); 24 task_scheduler_ = TaskScheduler::GetInstance();
31 } 25 }
32 26
33 ScopedAsyncTaskScheduler::~ScopedAsyncTaskScheduler() { 27 ScopedAsyncTaskScheduler::~ScopedAsyncTaskScheduler() {
34 DCHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_); 28 DCHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_);
35 TaskScheduler::GetInstance()->Shutdown(); 29 TaskScheduler::GetInstance()->Shutdown();
36 static_cast<internal::TaskSchedulerImpl*>(TaskScheduler::GetInstance()) 30 TaskScheduler::GetInstance()->JoinForTesting();
37 ->JoinForTesting();
38 TaskScheduler::SetInstance(nullptr); 31 TaskScheduler::SetInstance(nullptr);
39 } 32 }
40 33
41 } // namespace test 34 } // namespace test
42 } // namespace base 35 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_scheduler_impl_unittest.cc ('k') | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698