OLD | NEW |
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/memory/ptr_util.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 GetInstance()->Start( | 58 GetInstance()->Start( |
59 {{StandbyThreadPolicy::LAZY, kBackgroundMaxThreads, | 59 {{StandbyThreadPolicy::LAZY, kBackgroundMaxThreads, |
60 kSuggestedReclaimTime}, | 60 kSuggestedReclaimTime}, |
61 {StandbyThreadPolicy::LAZY, kBackgroundBlockingMaxThreads, | 61 {StandbyThreadPolicy::LAZY, kBackgroundBlockingMaxThreads, |
62 kSuggestedReclaimTime}, | 62 kSuggestedReclaimTime}, |
63 {StandbyThreadPolicy::LAZY, kForegroundMaxThreads, | 63 {StandbyThreadPolicy::LAZY, kForegroundMaxThreads, |
64 kSuggestedReclaimTime}, | 64 kSuggestedReclaimTime}, |
65 {StandbyThreadPolicy::LAZY, kForegroundBlockingMaxThreads, | 65 {StandbyThreadPolicy::LAZY, kForegroundBlockingMaxThreads, |
66 kSuggestedReclaimTime}}); | 66 kSuggestedReclaimTime}}); |
67 } | 67 } |
68 | |
69 // static | |
70 void TaskScheduler::CreateAndSetSimpleTaskScheduler(StringPiece name) { | |
71 CreateAndStartWithDefaultParams(name); | |
72 } | |
73 #endif // !defined(OS_NACL) | 68 #endif // !defined(OS_NACL) |
74 | 69 |
75 void TaskScheduler::Create(StringPiece name) { | 70 void TaskScheduler::Create(StringPiece name) { |
76 SetInstance(MakeUnique<internal::TaskSchedulerImpl>(name)); | 71 SetInstance(MakeUnique<internal::TaskSchedulerImpl>(name)); |
77 } | 72 } |
78 | 73 |
79 void TaskScheduler::CreateAndSetDefaultTaskScheduler( | 74 void TaskScheduler::CreateAndSetDefaultTaskScheduler( |
80 StringPiece name, | 75 StringPiece name, |
81 const InitParams& init_params) { | 76 const InitParams& init_params) { |
82 Create(name); | 77 Create(name); |
83 GetInstance()->Start(init_params); | 78 GetInstance()->Start(init_params); |
84 } | 79 } |
85 | 80 |
86 // static | 81 // static |
87 void TaskScheduler::SetInstance(std::unique_ptr<TaskScheduler> task_scheduler) { | 82 void TaskScheduler::SetInstance(std::unique_ptr<TaskScheduler> task_scheduler) { |
88 delete g_task_scheduler; | 83 delete g_task_scheduler; |
89 g_task_scheduler = task_scheduler.release(); | 84 g_task_scheduler = task_scheduler.release(); |
90 } | 85 } |
91 | 86 |
92 // static | 87 // static |
93 TaskScheduler* TaskScheduler::GetInstance() { | 88 TaskScheduler* TaskScheduler::GetInstance() { |
94 return g_task_scheduler; | 89 return g_task_scheduler; |
95 } | 90 } |
96 | 91 |
97 } // namespace base | 92 } // namespace base |
OLD | NEW |