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

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

Issue 2834063002: Separate the create and start phases in TaskSchedulerImpl. (Closed)
Patch Set: CR-robliao-25-grammar Created 3 years, 7 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/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/sys_info.h" 11 #include "base/sys_info.h"
11 #include "base/task_scheduler/scheduler_worker_pool_params.h" 12 #include "base/task_scheduler/scheduler_worker_pool_params.h"
12 #include "base/task_scheduler/task_scheduler_impl.h" 13 #include "base/task_scheduler/task_scheduler_impl.h"
13 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 16
16 namespace base { 17 namespace base {
17 18
18 namespace { 19 namespace {
19 20
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 {StandbyThreadPolicy::LAZY, kForegroundMaxThreads, 62 {StandbyThreadPolicy::LAZY, kForegroundMaxThreads,
62 kSuggestedReclaimTime}, 63 kSuggestedReclaimTime},
63 {StandbyThreadPolicy::LAZY, kForegroundBlockingMaxThreads, 64 {StandbyThreadPolicy::LAZY, kForegroundBlockingMaxThreads,
64 kSuggestedReclaimTime}}); 65 kSuggestedReclaimTime}});
65 } 66 }
66 #endif // !defined(OS_NACL) 67 #endif // !defined(OS_NACL)
67 68
68 void TaskScheduler::CreateAndSetDefaultTaskScheduler( 69 void TaskScheduler::CreateAndSetDefaultTaskScheduler(
69 StringPiece name, 70 StringPiece name,
70 const InitParams& init_params) { 71 const InitParams& init_params) {
71 SetInstance(internal::TaskSchedulerImpl::Create(name, init_params)); 72 SetInstance(MakeUnique<internal::TaskSchedulerImpl>(name));
73 GetInstance()->Start(init_params);
72 } 74 }
73 75
74 // static 76 // static
75 void TaskScheduler::SetInstance(std::unique_ptr<TaskScheduler> task_scheduler) { 77 void TaskScheduler::SetInstance(std::unique_ptr<TaskScheduler> task_scheduler) {
76 delete g_task_scheduler; 78 delete g_task_scheduler;
77 g_task_scheduler = task_scheduler.release(); 79 g_task_scheduler = task_scheduler.release();
78 } 80 }
79 81
80 // static 82 // static
81 TaskScheduler* TaskScheduler::GetInstance() { 83 TaskScheduler* TaskScheduler::GetInstance() {
82 return g_task_scheduler; 84 return g_task_scheduler;
83 } 85 }
84 86
85 } // namespace base 87 } // 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