Chromium Code Reviews| Index: base/task_scheduler/scheduler_single_thread_worker_pool_manager.h |
| diff --git a/base/task_scheduler/scheduler_single_thread_worker_pool_manager.h b/base/task_scheduler/scheduler_single_thread_worker_pool_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..76ffa6717afbd848338937712f635869cbada2f6 |
| --- /dev/null |
| +++ b/base/task_scheduler/scheduler_single_thread_worker_pool_manager.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_WORKER_POOL_MANAGER_H_ |
| +#define BASE_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_WORKER_POOL_MANAGER_H_ |
| + |
| +#include <stddef.h> |
| + |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "base/base_export.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/task_scheduler/scheduler_lock.h" |
| +#include "base/task_scheduler/scheduler_worker_pool_impl.h" |
| +#include "base/task_scheduler/task_scheduler.h" |
| +#include "base/time/time.h" |
|
fdoray
2017/01/27 16:47:35
Not used
robliao
2017/01/27 21:25:41
Done.
|
| + |
| +namespace base { |
| + |
| +class SchedulerWorkerPoolParams; |
| +class TaskTraits; |
| + |
| +namespace internal { |
| + |
| +class DelayedTaskManager; |
| +class TaskTracker; |
| + |
| +// Manages a pool of single-threaded worker pools mapped to one |
| +// SingleThreadTaskRunner. |
| +// |
| +// To maintain the same single thread threading environment for the trait |
| +// targeting a SchedulerWorkerPoolImpl, this also maintains the original |
| +// incoming SchedulerWorkerPoolParams and the WorkerPoolIndexForTraitsCallback |
| +// 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.
|
| +// |
| +// A single SingleThreadSchedulerWorkerPoolImplPool maintains a pool of |
| +// SchedulerWorkerPoolImpls of SchedulerWorkerPoolParams parameters. These are |
| +// held by |worker_pool_impl_pools_| and indexed the same way as |
| +// SchedulerWorkerPoolImpls in TaskSchedulerImpl. |
| +class BASE_EXPORT SchedulerSingleThreadWorkerPoolManager final { |
| + public: |
| + SchedulerSingleThreadWorkerPoolManager( |
| + const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, |
| + const TaskScheduler::WorkerPoolIndexForTraitsCallback& |
| + worker_pool_index_for_traits_callback, |
| + TaskTracker* task_tracker, |
| + DelayedTaskManager* delayed_task_manager); |
| + ~SchedulerSingleThreadWorkerPoolManager(); |
| + |
| + scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits( |
| + const TaskTraits& traits); |
| + |
| + void JoinForTesting(); |
| + void WaitForAllWorkersIdleForTesting(); |
| + |
| + private: |
| + class SingleThreadSchedulerWorkerPoolImplPool; |
| + |
| + 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.
|
| + const TaskScheduler::WorkerPoolIndexForTraitsCallback |
| + worker_pool_index_for_traits_callback_; |
| + |
| + // Synchronizes access to |worker_pool_impl_pools_|. |
| + SchedulerLock lock_; |
| + std::vector<std::unique_ptr<SingleThreadSchedulerWorkerPoolImplPool>> |
| + worker_pool_impl_pools_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SchedulerSingleThreadWorkerPoolManager); |
| +}; |
| + |
| +} // namespace internal |
| +} // namespace base |
| + |
| +#endif // BASE_TASK_SCHEDULER_SCHEDULER_SINGLE_THREAD_WORKER_POOL_MANAGER_H_ |