| 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 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 5 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
| 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 #endif // !defined(OS_NACL) | 160 #endif // !defined(OS_NACL) |
| 161 | 161 |
| 162 // Creates a ready to start task scheduler. |name| is used to label threads | 162 // Creates a ready to start task scheduler. |name| is used to label threads |
| 163 // and histograms. It should identify the component that creates the | 163 // and histograms. It should identify the component that creates the |
| 164 // TaskScheduler. The task scheduler doesn't create threads until Start() is | 164 // TaskScheduler. The task scheduler doesn't create threads until Start() is |
| 165 // called. Tasks can be posted at any time but will not run until after | 165 // called. Tasks can be posted at any time but will not run until after |
| 166 // Start() is called. For tests, prefer base::test::ScopedTaskEnvironment | 166 // Start() is called. For tests, prefer base::test::ScopedTaskEnvironment |
| 167 // (ensures isolation). | 167 // (ensures isolation). |
| 168 static void Create(StringPiece name); | 168 static void Create(StringPiece name); |
| 169 | 169 |
| 170 // Deprecated. Use Create() and Start() instead. | |
| 171 // TODO(fdoray): Redirect callers to Create() and Start(). | |
| 172 static void CreateAndSetDefaultTaskScheduler(StringPiece name, | |
| 173 const InitParams& init_params); | |
| 174 | |
| 175 // Registers |task_scheduler| to handle tasks posted through the post_task.h | 170 // Registers |task_scheduler| to handle tasks posted through the post_task.h |
| 176 // API for this process. For tests, prefer base::test::ScopedTaskScheduler | 171 // API for this process. For tests, prefer base::test::ScopedTaskScheduler |
| 177 // (ensures isolation). | 172 // (ensures isolation). |
| 178 static void SetInstance(std::unique_ptr<TaskScheduler> task_scheduler); | 173 static void SetInstance(std::unique_ptr<TaskScheduler> task_scheduler); |
| 179 | 174 |
| 180 // Retrieve the TaskScheduler set via SetInstance() or | 175 // Retrieve the TaskScheduler set via SetInstance() or |
| 181 // CreateAndSet(Simple|Default)TaskScheduler(). This should be used very | 176 // CreateAndSet(Simple|Default)TaskScheduler(). This should be used very |
| 182 // rarely; most users of TaskScheduler should use the post_task.h API. In | 177 // rarely; most users of TaskScheduler should use the post_task.h API. In |
| 183 // particular, refrain from doing | 178 // particular, refrain from doing |
| 184 // if (!TaskScheduler::GetInstance()) { | 179 // if (!TaskScheduler::GetInstance()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 201 // each process n/GetMaxConcurrentTasksWithTraitsDeprecated() items. | 196 // each process n/GetMaxConcurrentTasksWithTraitsDeprecated() items. |
| 202 // | 197 // |
| 203 // TODO(fdoray): Remove this method. https://crbug.com/687264 | 198 // TODO(fdoray): Remove this method. https://crbug.com/687264 |
| 204 virtual int GetMaxConcurrentTasksWithTraitsDeprecated( | 199 virtual int GetMaxConcurrentTasksWithTraitsDeprecated( |
| 205 const TaskTraits& traits) const = 0; | 200 const TaskTraits& traits) const = 0; |
| 206 }; | 201 }; |
| 207 | 202 |
| 208 } // namespace base | 203 } // namespace base |
| 209 | 204 |
| 210 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 205 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
| OLD | NEW |