Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3559)

Unified Diff: base/task_scheduler/scheduler_single_thread_worker_pool_manager.h

Issue 2650383007: Move Task Scheduler Single Thread Task Runners to Dedicated Threads (Closed)
Patch Set: CR Feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/task_scheduler/scheduler_single_thread_worker_pool_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « base/BUILD.gn ('k') | base/task_scheduler/scheduler_single_thread_worker_pool_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698