Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_WORKER_POOL_MANAGER_H_ | |
| 6 #define BASE_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_WORKER_POOL_MANAGER_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/base_export.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "base/memory/ref_counted.h" | |
| 16 #include "base/single_thread_task_runner.h" | |
| 17 #include "base/task_scheduler/scheduler_lock.h" | |
| 18 #include "base/task_scheduler/scheduler_worker_pool_impl.h" | |
| 19 #include "base/task_scheduler/task_scheduler.h" | |
| 20 #include "base/time/time.h" | |
|
fdoray
2017/01/27 16:47:35
Not used
robliao
2017/01/27 21:25:41
Done.
| |
| 21 | |
| 22 namespace base { | |
| 23 | |
| 24 class SchedulerWorkerPoolParams; | |
| 25 class TaskTraits; | |
| 26 | |
| 27 namespace internal { | |
| 28 | |
| 29 class DelayedTaskManager; | |
| 30 class TaskTracker; | |
| 31 | |
| 32 // Manages a pool of single-threaded worker pools mapped to one | |
| 33 // SingleThreadTaskRunner. | |
| 34 // | |
| 35 // To maintain the same single thread threading environment for the trait | |
| 36 // targeting a SchedulerWorkerPoolImpl, this also maintains the original | |
| 37 // incoming SchedulerWorkerPoolParams and the WorkerPoolIndexForTraitsCallback | |
| 38 // to create a single thread WorkerPool of the exact same threading environment. | |
|
fdoray
2017/01/27 16:47:35
s/WorkerPool/SchedulerWorkerPoolImpl/
robliao
2017/01/27 21:25:41
Done.
| |
| 39 // | |
| 40 // A single SingleThreadSchedulerWorkerPoolImplPool maintains a pool of | |
| 41 // SchedulerWorkerPoolImpls of SchedulerWorkerPoolParams parameters. These are | |
| 42 // held by |worker_pool_impl_pools_| and indexed the same way as | |
| 43 // SchedulerWorkerPoolImpls in TaskSchedulerImpl. | |
| 44 class BASE_EXPORT SchedulerSingleThreadWorkerPoolManager final { | |
| 45 public: | |
| 46 SchedulerSingleThreadWorkerPoolManager( | |
| 47 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, | |
| 48 const TaskScheduler::WorkerPoolIndexForTraitsCallback& | |
| 49 worker_pool_index_for_traits_callback, | |
| 50 TaskTracker* task_tracker, | |
| 51 DelayedTaskManager* delayed_task_manager); | |
| 52 ~SchedulerSingleThreadWorkerPoolManager(); | |
| 53 | |
| 54 scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits( | |
| 55 const TaskTraits& traits); | |
| 56 | |
| 57 void JoinForTesting(); | |
| 58 void WaitForAllWorkersIdleForTesting(); | |
| 59 | |
| 60 private: | |
| 61 class SingleThreadSchedulerWorkerPoolImplPool; | |
| 62 | |
| 63 const std::vector<SchedulerWorkerPoolParams> worker_pool_params_vector_; | |
|
fdoray
2017/01/27 16:47:35
Not needed (only used in the constructor).
robliao
2017/01/27 21:25:41
Done.
| |
| 64 const TaskScheduler::WorkerPoolIndexForTraitsCallback | |
| 65 worker_pool_index_for_traits_callback_; | |
| 66 | |
| 67 // Synchronizes access to |worker_pool_impl_pools_|. | |
| 68 SchedulerLock lock_; | |
| 69 std::vector<std::unique_ptr<SingleThreadSchedulerWorkerPoolImplPool>> | |
| 70 worker_pool_impl_pools_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(SchedulerSingleThreadWorkerPoolManager); | |
| 73 }; | |
| 74 | |
| 75 } // namespace internal | |
| 76 } // namespace base | |
| 77 | |
| 78 #endif // BASE_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_WORKER_POOL_MANAGER_H_ | |
| OLD | NEW |