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..9b2103a93b36706eac8347088e16b44752af3943 |
--- /dev/null |
+++ b/base/task_scheduler/task_scheduler_impl.h |
@@ -0,0 +1,63 @@ |
+// 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 task_scheduler { |
+ |
+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; |
+ |
+ // Waits until all threads have exited. Shutdown() must have been called |
+ // before this is called, otherwise the threads won't exit. |
+ void JoinAllThreadsForTesting(); |
robliao
2016/02/11 21:56:27
Is it ever valid to call this without calling Shut
fdoray
2016/02/12 04:16:20
Done.
|
+ |
+ 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<task_scheduler::Sequence> sequence, |
+ const task_scheduler::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 task_scheduler |
+} // namespace base |
+ |
+#endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |