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

Unified Diff: base/task_scheduler/task_scheduler_impl.h

Issue 1698183005: Reference CL for the new task scheduler. (Closed) Base URL: https://luckyluke-private.googlesource.com/src@bigmaster2
Patch Set: Created 4 years, 10 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/task_scheduler/task_scheduler.cc ('k') | base/task_scheduler/task_scheduler_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/task_scheduler_impl.h
diff --git a/base/task_scheduler/task_scheduler_impl.h b/base/task_scheduler/task_scheduler_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..5d085713e8e4ca51abe16794ee6040c493dda38a
--- /dev/null
+++ b/base/task_scheduler/task_scheduler_impl.h
@@ -0,0 +1,62 @@
+// Copyright 2016 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_TASK_SCHEDULER_IMPL_H_
+#define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
+
+#include "base/base_export.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/task_scheduler/sequence.h"
+#include "base/task_scheduler/shutdown_manager.h"
+#include "base/task_scheduler/task_scheduler.h"
+#include "base/task_scheduler/thread_pool.h"
+
+namespace base {
+namespace internal {
+
+class WorkerThread;
+
+class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
+ public:
+ TaskSchedulerImpl();
+ ~TaskSchedulerImpl() override;
+
+ // TaskScheduler:
+ void PostTaskWithTraits(const tracked_objects::Location& from_here,
+ TaskTraits traits,
+ const Closure& task) override;
+ scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
+ TaskTraits traits,
+ ExecutionMode execution_mode) override;
+ void Shutdown() override;
+
+ // Initiates shutdown and waits until all threads have exited. This method
+ // must not be called more than once in the lifetime of the TaskSchedulerImpl.
+ void ShutdownAndJoinAllThreadsForTesting();
+
+ private:
+ // Returns the thread pool that should run tasks with |traits|.
+ ThreadPool* GetThreadPoolForTraits(const TaskTraits& traits);
+
+ // Callback invoked by |worker_thread| to reinsert |sequence| in the
+ // appropriate priority queue after it has executed one of its tasks.
+ void ReinsertSequenceCallback(scoped_refptr<Sequence> sequence,
+ const WorkerThread* worker_thread);
+
+ ShutdownManager shutdown_manager_;
+
+ scoped_ptr<ThreadPool> background_thread_pool_;
+ scoped_ptr<ThreadPool> background_file_io_thread_pool_;
+ scoped_ptr<ThreadPool> normal_thread_pool_;
+ scoped_ptr<ThreadPool> normal_file_io_thread_pool_;
+
+ DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl);
+};
+
+} // namespace internal
+} // namespace base
+
+#endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
« no previous file with comments | « base/task_scheduler/task_scheduler.cc ('k') | base/task_scheduler/task_scheduler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698