| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ | 5 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
| 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ | 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/synchronization/atomic_flag.h" | 18 #include "base/synchronization/atomic_flag.h" |
| 19 #include "base/task_runner.h" | |
| 20 #include "base/task_scheduler/scheduler_worker_pool_impl.h" | 19 #include "base/task_scheduler/scheduler_worker_pool_impl.h" |
| 21 #include "base/task_scheduler/sequence.h" | 20 #include "base/task_scheduler/sequence.h" |
| 22 #include "base/task_scheduler/task_scheduler.h" | 21 #include "base/task_scheduler/task_scheduler.h" |
| 23 #include "base/task_scheduler/task_traits.h" | 22 #include "base/task_scheduler/task_traits.h" |
| 24 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
| 25 | 24 |
| 26 namespace base { | 25 namespace base { |
| 27 | 26 |
| 28 class HistogramBase; | 27 class HistogramBase; |
| 29 class SchedulerWorkerPoolParams; | 28 class SchedulerWorkerPoolParams; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 49 // Destroying a TaskSchedulerImpl is not allowed in production; it is always | 48 // Destroying a TaskSchedulerImpl is not allowed in production; it is always |
| 50 // leaked. In tests, it can only be destroyed after JoinForTesting() has | 49 // leaked. In tests, it can only be destroyed after JoinForTesting() has |
| 51 // returned. | 50 // returned. |
| 52 ~TaskSchedulerImpl() override; | 51 ~TaskSchedulerImpl() override; |
| 53 | 52 |
| 54 // TaskScheduler: | 53 // TaskScheduler: |
| 55 void PostTaskWithTraits(const tracked_objects::Location& from_here, | 54 void PostTaskWithTraits(const tracked_objects::Location& from_here, |
| 56 const TaskTraits& traits, | 55 const TaskTraits& traits, |
| 57 const Closure& task) override; | 56 const Closure& task) override; |
| 58 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( | 57 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( |
| 59 const TaskTraits& traits, | 58 const TaskTraits& traits) override; |
| 60 ExecutionMode execution_mode) override; | 59 scoped_refptr<SequencedTaskRunner> CreateSequencedTaskRunnerWithTraits( |
| 60 const TaskTraits& traits) override; |
| 61 scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits( |
| 62 const TaskTraits& traits) override; |
| 61 std::vector<const HistogramBase*> GetHistograms() const override; | 63 std::vector<const HistogramBase*> GetHistograms() const override; |
| 62 void Shutdown() override; | 64 void Shutdown() override; |
| 63 void FlushForTesting() override; | 65 void FlushForTesting() override; |
| 64 | 66 |
| 65 // Joins all threads of this scheduler. Tasks that are already running are | 67 // Joins all threads of this scheduler. Tasks that are already running are |
| 66 // allowed to complete their execution. This can only be called once. | 68 // allowed to complete their execution. This can only be called once. |
| 67 void JoinForTesting(); | 69 void JoinForTesting(); |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 explicit TaskSchedulerImpl(const WorkerPoolIndexForTraitsCallback& | 72 explicit TaskSchedulerImpl(const WorkerPoolIndexForTraitsCallback& |
| (...skipping 20 matching lines...) Expand all Loading... |
| 91 AtomicFlag join_for_testing_returned_; | 93 AtomicFlag join_for_testing_returned_; |
| 92 #endif | 94 #endif |
| 93 | 95 |
| 94 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); | 96 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 } // namespace internal | 99 } // namespace internal |
| 98 } // namespace base | 100 } // namespace base |
| 99 | 101 |
| 100 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ | 102 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
| OLD | NEW |