| 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..9d1b070a4c234595e70f80d50412c5bf230bf422
|
| --- /dev/null
|
| +++ b/base/task_scheduler/scheduler_single_thread_worker_pool_manager.h
|
| @@ -0,0 +1,77 @@
|
| +// 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"
|
| +
|
| +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 SchedulerWorkerPoolImpl of the exact same threading
|
| +// environment.
|
| +//
|
| +// 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 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_
|
|
|