Chromium Code Reviews| Index: base/task_scheduler/scheduler_thread_pool_impl.h |
| diff --git a/base/task_scheduler/scheduler_thread_pool.h b/base/task_scheduler/scheduler_thread_pool_impl.h |
| similarity index 77% |
| copy from base/task_scheduler/scheduler_thread_pool.h |
| copy to base/task_scheduler/scheduler_thread_pool_impl.h |
| index 7afdd990854e155e009fa6a50e9f330de49305b1..d040b4a2d138a8fa9b0abad1d5727506e679906d 100644 |
| --- a/base/task_scheduler/scheduler_thread_pool.h |
| +++ b/base/task_scheduler/scheduler_thread_pool_impl.h |
| @@ -2,8 +2,8 @@ |
| // 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_THREAD_POOL_H_ |
| -#define BASE_TASK_SCHEDULER_SCHEDULER_THREAD_POOL_H_ |
| +#ifndef BASE_TASK_SCHEDULER_SCHEDULER_THREAD_POOL_IMPL_H_ |
| +#define BASE_TASK_SCHEDULER_SCHEDULER_THREAD_POOL_IMPL_H_ |
| #include <stddef.h> |
| @@ -18,7 +18,7 @@ |
| #include "base/task_runner.h" |
| #include "base/task_scheduler/priority_queue.h" |
| #include "base/task_scheduler/scheduler_lock.h" |
| -#include "base/task_scheduler/scheduler_task_executor.h" |
| +#include "base/task_scheduler/scheduler_thread_pool.h" |
| #include "base/task_scheduler/scheduler_worker_thread.h" |
| #include "base/task_scheduler/scheduler_worker_thread_stack.h" |
| #include "base/task_scheduler/sequence.h" |
| @@ -34,7 +34,7 @@ struct SequenceSortKey; |
| class TaskTracker; |
| // A pool of threads that run Tasks. This class is thread-safe. |
| -class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor { |
| +class BASE_EXPORT SchedulerThreadPoolImpl : public SchedulerThreadPool { |
| public: |
| // Callback invoked when a Sequence isn't empty after a worker thread pops a |
| // Task from it. |
| @@ -43,7 +43,7 @@ class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor { |
| // Destroying a SchedulerThreadPool returned by CreateThreadPool() is not |
| // allowed in production; it is always leaked. In tests, it can only be |
| // destroyed after JoinForTesting() has returned. |
| - ~SchedulerThreadPool() override; |
| + ~SchedulerThreadPoolImpl() override; |
| // Creates a SchedulerThreadPool with up to |max_threads| threads of priority |
| // |thread_priority|. |enqueue_sequence_callback| will be invoked after a |
| @@ -51,26 +51,13 @@ class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor { |
| // handle shutdown behavior of Tasks. |delayed_task_manager| handles Tasks |
| // posted with a delay. Returns nullptr on failure to create a thread pool |
| // with at least one thread. |
| - static std::unique_ptr<SchedulerThreadPool> CreateThreadPool( |
| + static std::unique_ptr<SchedulerThreadPoolImpl> CreateThreadPool( |
| ThreadPriority thread_priority, |
| size_t max_threads, |
| const EnqueueSequenceCallback& enqueue_sequence_callback, |
| TaskTracker* task_tracker, |
| DelayedTaskManager* delayed_task_manager); |
| - // Returns a TaskRunner whose PostTask invocations will result in scheduling |
| - // Tasks with |traits| and |execution_mode| in this thread pool. |
| - scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( |
| - const TaskTraits& traits, |
| - ExecutionMode execution_mode); |
| - |
| - // Inserts |sequence| into this thread pool's shared priority queue with |
| - // |sequence_sort_key|. Must only be called from a worker thread to put |
| - // |sequence| back into a PriorityQueue after running a Task from it. The |
| - // worker thread doesn't have to belong to this thread pool. |
| - void EnqueueSequence(scoped_refptr<Sequence> sequence, |
| - const SequenceSortKey& sequence_sort_key); |
| - |
| // Waits until all threads are idle. |
| void WaitForAllWorkerThreadsIdleForTesting(); |
| @@ -78,16 +65,24 @@ class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor { |
| // allowed to complete their execution. This can only be called once. |
| void JoinForTesting(); |
| - // SchedulerTaskExecutor: |
| - void PostTaskWithSequence(std::unique_ptr<Task> task, |
| + // SchedulerThreadPool: |
| + scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( |
|
robliao
2016/04/22 22:56:41
Can these be made private or do we have callers th
fdoray
2016/04/25 15:19:12
Relevant discussions:
tl;dr Overrides are public
robliao
2016/04/25 20:08:09
The chromium-dev discussion on the topic is here:
|
| + const TaskTraits& traits, |
| + ExecutionMode execution_mode) override; |
| + void EnqueueSequence(scoped_refptr<Sequence> sequence, |
| + const SequenceSortKey& sequence_sort_key) override; |
| + bool PostTaskWithSequence(std::unique_ptr<Task> task, |
| scoped_refptr<Sequence> sequence) override; |
| + void PostTaskWithSequenceNow(std::unique_ptr<Task> task, |
| + scoped_refptr<Sequence> sequence) override; |
| private: |
| class SchedulerWorkerThreadDelegateImpl; |
| - SchedulerThreadPool(const EnqueueSequenceCallback& enqueue_sequence_callback, |
| - TaskTracker* task_tracker, |
| - DelayedTaskManager* delayed_task_manager); |
| + SchedulerThreadPoolImpl( |
| + const EnqueueSequenceCallback& enqueue_sequence_callback, |
| + TaskTracker* task_tracker, |
| + DelayedTaskManager* delayed_task_manager); |
| bool Initialize(ThreadPriority thread_priority, size_t max_threads); |
| @@ -126,10 +121,10 @@ class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor { |
| TaskTracker* const task_tracker_; |
| DelayedTaskManager* const delayed_task_manager_; |
| - DISALLOW_COPY_AND_ASSIGN(SchedulerThreadPool); |
| + DISALLOW_COPY_AND_ASSIGN(SchedulerThreadPoolImpl); |
| }; |
| } // namespace internal |
| } // namespace base |
| -#endif // BASE_TASK_SCHEDULER_SCHEDULER_THREAD_POOL_H_ |
| +#endif // BASE_TASK_SCHEDULER_SCHEDULER_THREAD_POOL_IMPL_H_ |