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_TRACKER_H_ | 5 #ifndef BASE_TASK_SCHEDULER_TASK_TRACKER_H_ |
6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_ | 6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 // Records the TaskScheduler.TaskLatency.[task priority].[may block] histogram | 111 // Records the TaskScheduler.TaskLatency.[task priority].[may block] histogram |
112 // for |task|. | 112 // for |task|. |
113 void RecordTaskLatencyHistogram(Task* task); | 113 void RecordTaskLatencyHistogram(Task* task); |
114 | 114 |
115 // Number of tasks blocking shutdown and boolean indicating whether shutdown | 115 // Number of tasks blocking shutdown and boolean indicating whether shutdown |
116 // has started. | 116 // has started. |
117 const std::unique_ptr<State> state_; | 117 const std::unique_ptr<State> state_; |
118 | 118 |
119 // Number of undelayed tasks that haven't completed their execution. Is | 119 // Number of undelayed tasks that haven't completed their execution. Is |
120 // incremented and decremented without a barrier. When it reaches zero, | 120 // decremented with a memory barrier after a task runs. Is accessed with an |
121 // |flush_lock_| is acquired (forcing memory synchronization) and |flush_cv_| | 121 // acquire memory barrier in Flush(). The memory barriers ensure that the |
122 // is signaled. | 122 // memory written by flushed tasks is visible when Flush() returns. |
123 subtle::Atomic32 num_pending_undelayed_tasks_ = 0; | 123 subtle::Atomic32 num_pending_undelayed_tasks_ = 0; |
124 | 124 |
125 // Lock associated with |flush_cv_|. Partially synchronizes access to | 125 // Lock associated with |flush_cv_|. Partially synchronizes access to |
126 // |num_pending_undelayed_tasks_|. Full synchronization isn't needed because | 126 // |num_pending_undelayed_tasks_|. Full synchronization isn't needed because |
127 // it's atomic, but synchronization is needed to coordinate waking and | 127 // it's atomic, but synchronization is needed to coordinate waking and |
128 // sleeping at the right time. | 128 // sleeping at the right time. |
129 mutable SchedulerLock flush_lock_; | 129 mutable SchedulerLock flush_lock_; |
130 | 130 |
131 // Signaled when |num_pending_undelayed_tasks_| is zero or when shutdown | 131 // Signaled when |num_pending_undelayed_tasks_| is zero or when shutdown |
132 // completes. | 132 // completes. |
(...skipping 15 matching lines...) Expand all Loading... |
148 // Number of BLOCK_SHUTDOWN tasks posted during shutdown. | 148 // Number of BLOCK_SHUTDOWN tasks posted during shutdown. |
149 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; | 149 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; |
150 | 150 |
151 DISALLOW_COPY_AND_ASSIGN(TaskTracker); | 151 DISALLOW_COPY_AND_ASSIGN(TaskTracker); |
152 }; | 152 }; |
153 | 153 |
154 } // namespace internal | 154 } // namespace internal |
155 } // namespace base | 155 } // namespace base |
156 | 156 |
157 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_ | 157 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_ |
OLD | NEW |