| 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_IMPL_H_ | 5 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
| 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ | 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 class SchedulerWorkerPoolParams; | 31 class SchedulerWorkerPoolParams; |
| 32 | 32 |
| 33 namespace internal { | 33 namespace internal { |
| 34 | 34 |
| 35 class SchedulerServiceThread; | 35 class SchedulerServiceThread; |
| 36 | 36 |
| 37 // Default TaskScheduler implementation. This class is thread-safe. | 37 // Default TaskScheduler implementation. This class is thread-safe. |
| 38 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler { | 38 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler { |
| 39 public: | 39 public: |
| 40 // Returns the index of the worker pool in which a task with |traits| should | |
| 41 // run. This should be coded in a future-proof way: new traits should | |
| 42 // gracefully map to a default pool. | |
| 43 using WorkerPoolIndexForTraitsCallback = | |
| 44 Callback<size_t(const TaskTraits& traits)>; | |
| 45 | |
| 46 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure. | 40 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure. |
| 47 // |worker_pools| describes the worker pools to create. | 41 // |worker_pool_params_vector| describes the worker pools to create. |
| 48 // |worker_pool_index_for_traits_callback| returns the index in |worker_pools| | 42 // |worker_pool_index_for_traits_callback| returns the index in |worker_pools| |
| 49 // of the worker pool in which a task with given traits should run. | 43 // of the worker pool in which a task with given traits should run. |
| 50 static std::unique_ptr<TaskSchedulerImpl> Create( | 44 static std::unique_ptr<TaskSchedulerImpl> Create( |
| 51 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, | 45 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, |
| 52 const WorkerPoolIndexForTraitsCallback& | 46 const WorkerPoolIndexForTraitsCallback& |
| 53 worker_pool_index_for_traits_callback); | 47 worker_pool_index_for_traits_callback); |
| 54 | 48 |
| 55 // Destroying a TaskSchedulerImpl is not allowed in production; it is always | 49 // Destroying a TaskSchedulerImpl is not allowed in production; it is always |
| 56 // leaked. In tests, it can only be destroyed after JoinForTesting() has | 50 // leaked. In tests, it can only be destroyed after JoinForTesting() has |
| 57 // returned. | 51 // returned. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 AtomicFlag join_for_testing_returned_; | 93 AtomicFlag join_for_testing_returned_; |
| 100 #endif | 94 #endif |
| 101 | 95 |
| 102 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); | 96 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); |
| 103 }; | 97 }; |
| 104 | 98 |
| 105 } // namespace internal | 99 } // namespace internal |
| 106 } // namespace base | 100 } // namespace base |
| 107 | 101 |
| 108 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ | 102 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
| OLD | NEW |