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

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

Issue 2809163003: Always use TaskScheduler::InitParams to initialize a TaskScheduler. (Closed)
Patch Set: fix-build-error Created 3 years, 8 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
« no previous file with comments | « base/task_scheduler/task_scheduler.h ('k') | base/task_scheduler/task_scheduler_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "base/task_scheduler/task_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h"
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/sys_info.h" 10 #include "base/sys_info.h"
12 #include "base/task_scheduler/scheduler_worker_pool_params.h" 11 #include "base/task_scheduler/scheduler_worker_pool_params.h"
13 #include "base/task_scheduler/task_scheduler_impl.h" 12 #include "base/task_scheduler/task_scheduler_impl.h"
14 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 15
17 namespace base { 16 namespace base {
18 17
19 namespace { 18 namespace {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 kSuggestedReclaimTime}, 58 kSuggestedReclaimTime},
60 {StandbyThreadPolicy::LAZY, kBackgroundBlockingMaxThreads, 59 {StandbyThreadPolicy::LAZY, kBackgroundBlockingMaxThreads,
61 kSuggestedReclaimTime}, 60 kSuggestedReclaimTime},
62 {StandbyThreadPolicy::LAZY, kForegroundMaxThreads, 61 {StandbyThreadPolicy::LAZY, kForegroundMaxThreads,
63 kSuggestedReclaimTime}, 62 kSuggestedReclaimTime},
64 {StandbyThreadPolicy::LAZY, kForegroundBlockingMaxThreads, 63 {StandbyThreadPolicy::LAZY, kForegroundBlockingMaxThreads,
65 kSuggestedReclaimTime}}); 64 kSuggestedReclaimTime}});
66 } 65 }
67 #endif // !defined(OS_NACL) 66 #endif // !defined(OS_NACL)
68 67
69 // static
70 void TaskScheduler::CreateAndSetDefaultTaskScheduler(
71 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector,
72 const WorkerPoolIndexForTraitsCallback&
73 worker_pool_index_for_traits_callback) {
74 SetInstance(internal::TaskSchedulerImpl::Create(
75 worker_pool_params_vector, worker_pool_index_for_traits_callback));
76 }
77
78 void TaskScheduler::CreateAndSetDefaultTaskScheduler( 68 void TaskScheduler::CreateAndSetDefaultTaskScheduler(
79 const std::string& name, 69 const std::string& name,
80 const InitParams& init_params) { 70 const InitParams& init_params) {
81 SetInstance(internal::TaskSchedulerImpl::Create(name, init_params)); 71 SetInstance(internal::TaskSchedulerImpl::Create(name, init_params));
82 } 72 }
83 73
84 // static 74 // static
85 void TaskScheduler::SetInstance(std::unique_ptr<TaskScheduler> task_scheduler) { 75 void TaskScheduler::SetInstance(std::unique_ptr<TaskScheduler> task_scheduler) {
86 delete g_task_scheduler; 76 delete g_task_scheduler;
87 g_task_scheduler = task_scheduler.release(); 77 g_task_scheduler = task_scheduler.release();
88 } 78 }
89 79
90 // static 80 // static
91 TaskScheduler* TaskScheduler::GetInstance() { 81 TaskScheduler* TaskScheduler::GetInstance() {
92 return g_task_scheduler; 82 return g_task_scheduler;
93 } 83 }
94 84
95 } // namespace base 85 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_scheduler.h ('k') | base/task_scheduler/task_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698