Chromium Code Reviews| 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 <string> | |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/base_export.h" | 12 #include "base/base_export.h" |
| 12 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 16 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
| 17 #include "base/task_scheduler/task_traits.h" | 18 #include "base/task_scheduler/task_traits.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 | 101 |
| 101 // CreateAndSetSimpleTaskScheduler(), CreateAndSetDefaultTaskScheduler(), and | 102 // CreateAndSetSimpleTaskScheduler(), CreateAndSetDefaultTaskScheduler(), and |
| 102 // SetInstance() register a TaskScheduler to handle tasks posted through the | 103 // SetInstance() register a TaskScheduler to handle tasks posted through the |
| 103 // post_task.h API for this process. The registered TaskScheduler will only be | 104 // post_task.h API for this process. The registered TaskScheduler will only be |
| 104 // deleted when a new TaskScheduler is registered and is leaked on shutdown. | 105 // deleted when a new TaskScheduler is registered and is leaked on shutdown. |
| 105 // The methods must not be called when TaskRunners created by the previous | 106 // The methods must not be called when TaskRunners created by the previous |
| 106 // TaskScheduler are still alive. The methods are not thread-safe; proper | 107 // TaskScheduler are still alive. The methods are not thread-safe; proper |
| 107 // synchronization is required to use the post_task.h API after registering a | 108 // synchronization is required to use the post_task.h API after registering a |
| 108 // new TaskScheduler. | 109 // new TaskScheduler. |
| 109 | 110 |
| 110 // Creates and sets a task scheduler with one worker pool that can have up to | 111 // Creates and sets a task scheduler using default params. |name| will be used |
| 111 // |max_threads| threads. CHECKs on failure. For tests, prefer | 112 // to label threads and histograms. CHECKs on failure. For tests, prefer |
|
robliao
2017/03/13 23:56:05
Add guidance on choosing a name (e.g. it should id
fdoray
2017/03/14 15:08:22
Done.
| |
| 112 // base::test::ScopedTaskScheduler (ensures isolation). | 113 // base::test::ScopedTaskScheduler (ensures isolation). |
| 113 static void CreateAndSetSimpleTaskScheduler(int max_threads); | 114 static void CreateAndSetSimpleTaskScheduler(const std::string& name); |
|
robliao
2017/03/13 23:56:05
Note this change in the CL description.
fdoray
2017/03/14 15:08:22
Done.
| |
| 114 | 115 |
| 115 // Creates and sets a task scheduler with custom worker pools. CHECKs on | 116 // Creates and sets a task scheduler with custom worker pools. CHECKs on |
| 116 // failure. |worker_pool_params_vector| describes the worker pools to create. | 117 // failure. |worker_pool_params_vector| describes the worker pools to create. |
| 117 // |worker_pool_index_for_traits_callback| returns the index in |worker_pools| | 118 // |worker_pool_index_for_traits_callback| returns the index in |worker_pools| |
| 118 // of the worker pool in which a task with given traits should run. For tests, | 119 // of the worker pool in which a task with given traits should run. For tests, |
| 119 // prefer base::test::ScopedTaskScheduler (ensures isolation). | 120 // prefer base::test::ScopedTaskScheduler (ensures isolation). |
| 120 static void CreateAndSetDefaultTaskScheduler( | 121 static void CreateAndSetDefaultTaskScheduler( |
| 121 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, | 122 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, |
| 122 const WorkerPoolIndexForTraitsCallback& | 123 const WorkerPoolIndexForTraitsCallback& |
| 123 worker_pool_index_for_traits_callback); | 124 worker_pool_index_for_traits_callback); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 151 // each process n/GetMaxConcurrentTasksWithTraitsDeprecated() items. | 152 // each process n/GetMaxConcurrentTasksWithTraitsDeprecated() items. |
| 152 // | 153 // |
| 153 // TODO(fdoray): Remove this method. https://crbug.com/687264 | 154 // TODO(fdoray): Remove this method. https://crbug.com/687264 |
| 154 virtual int GetMaxConcurrentTasksWithTraitsDeprecated( | 155 virtual int GetMaxConcurrentTasksWithTraitsDeprecated( |
| 155 const TaskTraits& traits) const = 0; | 156 const TaskTraits& traits) const = 0; |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 } // namespace base | 159 } // namespace base |
| 159 | 160 |
| 160 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 161 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
| OLD | NEW |