Chromium Code Reviews| Index: base/task_scheduler/task_scheduler.h |
| diff --git a/base/task_scheduler/task_scheduler.h b/base/task_scheduler/task_scheduler.h |
| index 5f851b491cc7bf41434cd162134ca4828fa5ea2a..f37b622f46a6cfa39fbe2246b2753ecf4f3f38ea 100644 |
| --- a/base/task_scheduler/task_scheduler.h |
| +++ b/base/task_scheduler/task_scheduler.h |
| @@ -6,6 +6,7 @@ |
| #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
| #include <memory> |
| +#include <vector> |
| #include "base/base_export.h" |
| #include "base/callback_forward.h" |
| @@ -19,10 +20,18 @@ class Location; |
| namespace base { |
| +class SchedulerWorkerPoolParams; |
| + |
| // Interface for a task scheduler and static methods to manage the instance used |
| // by the post_task.h API. |
| class BASE_EXPORT TaskScheduler { |
| public: |
| + // Returns the index of the worker pool in which a task with |traits| should |
| + // run. This should be coded in a future-proof way: new traits should |
| + // gracefully map to a default pool. |
| + using WorkerPoolIndexForTraitsCallback = |
| + Callback<size_t(const TaskTraits& traits)>; |
| + |
| virtual ~TaskScheduler() = default; |
| // Posts |task| with specific |traits|. |
| @@ -48,6 +57,15 @@ class BASE_EXPORT TaskScheduler { |
| // called once. |
| virtual void Shutdown() = 0; |
|
fdoray
2016/08/02 15:01:29
Maybe write a comment that applies to both CreateA
robliao
2016/08/02 19:29:00
Done.
|
| + // Creates and sets a default task scheduler. CHECKs on failure. |
| + // |worker_pool_params_vector| describes the worker pools to create. |
| + // |worker_pool_index_for_traits_callback| returns the index in |worker_pools| |
| + // of the worker pool in which a task with given traits should run. |
| + static void CreateAndSetDefaultTaskScheduler( |
| + const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, |
| + const WorkerPoolIndexForTraitsCallback& |
| + worker_pool_index_for_traits_callback); |
| + |
| // Registers |task_scheduler| to handle tasks posted through the post_task.h |
| // API for this process. The registered TaskScheduler will only be deleted |
| // when a new TaskScheduler is registered (i.e. otherwise leaked on shutdown). |