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 <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "base/synchronization/atomic_flag.h" | 17 #include "base/synchronization/atomic_flag.h" |
18 #include "base/task_scheduler/delayed_task_manager.h" | 18 #include "base/task_scheduler/delayed_task_manager.h" |
19 #include "base/task_scheduler/scheduler_single_thread_task_runner_manager.h" | 19 #include "base/task_scheduler/scheduler_single_thread_task_runner_manager.h" |
20 #include "base/task_scheduler/scheduler_worker_pool_impl.h" | 20 #include "base/task_scheduler/scheduler_worker_pool_impl.h" |
21 #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_tracker.h" | 22 #include "base/task_scheduler/task_tracker.h" |
24 #include "base/task_scheduler/task_traits.h" | 23 #include "base/task_scheduler/task_traits.h" |
25 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
26 #include "build/build_config.h" | 25 #include "build/build_config.h" |
27 | 26 |
28 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) | 27 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) |
29 #include "base/task_scheduler/task_tracker_posix.h" | 28 #include "base/task_scheduler/task_tracker_posix.h" |
30 #endif | 29 #endif |
31 | 30 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const TaskTraits& traits) const override; | 62 const TaskTraits& traits) const override; |
64 void Shutdown() override; | 63 void Shutdown() override; |
65 void FlushForTesting() override; | 64 void FlushForTesting() override; |
66 void JoinForTesting() override; | 65 void JoinForTesting() override; |
67 | 66 |
68 private: | 67 private: |
69 // Returns the worker pool that runs Tasks with |traits|. | 68 // Returns the worker pool that runs Tasks with |traits|. |
70 SchedulerWorkerPoolImpl* GetWorkerPoolForTraits( | 69 SchedulerWorkerPoolImpl* GetWorkerPoolForTraits( |
71 const TaskTraits& traits) const; | 70 const TaskTraits& traits) const; |
72 | 71 |
73 // Callback invoked when a non-single-thread |sequence| isn't empty after a | |
74 // worker pops a Task from it. | |
75 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence); | |
76 | |
77 const std::string name_; | 72 const std::string name_; |
78 Thread service_thread_; | 73 Thread service_thread_; |
79 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) | 74 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) |
80 TaskTrackerPosix task_tracker_; | 75 TaskTrackerPosix task_tracker_; |
81 #else | 76 #else |
82 TaskTracker task_tracker_; | 77 TaskTracker task_tracker_; |
83 #endif | 78 #endif |
84 DelayedTaskManager delayed_task_manager_; | 79 DelayedTaskManager delayed_task_manager_; |
85 SchedulerSingleThreadTaskRunnerManager single_thread_task_runner_manager_; | 80 SchedulerSingleThreadTaskRunnerManager single_thread_task_runner_manager_; |
86 | 81 |
87 // There are 4 SchedulerWorkerPoolImpl in this array to match the 4 | 82 // There are 4 SchedulerWorkerPoolImpl in this array to match the 4 |
88 // SchedulerWorkerPoolParams in TaskScheduler::InitParams. | 83 // SchedulerWorkerPoolParams in TaskScheduler::InitParams. |
89 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4]; | 84 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4]; |
90 | 85 |
91 #if DCHECK_IS_ON() | 86 #if DCHECK_IS_ON() |
92 // Set once JoinForTesting() has returned. | 87 // Set once JoinForTesting() has returned. |
93 AtomicFlag join_for_testing_returned_; | 88 AtomicFlag join_for_testing_returned_; |
94 #endif | 89 #endif |
95 | 90 |
96 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); | 91 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); |
97 }; | 92 }; |
98 | 93 |
99 } // namespace internal | 94 } // namespace internal |
100 } // namespace base | 95 } // namespace base |
101 | 96 |
102 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ | 97 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ |
OLD | NEW |