| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/pending_task.h" | 14 #include "base/pending_task.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "base/trace_event/trace_event_argument.h" | 17 #include "base/trace_event/trace_event_argument.h" |
| 18 #include "platform/scheduler/base/enqueue_order.h" | 18 #include "platform/scheduler/base/enqueue_order.h" |
| 19 #include "platform/scheduler/base/intrusive_heap.h" | |
| 20 #include "public/platform/scheduler/base/task_queue.h" | 19 #include "public/platform/scheduler/base/task_queue.h" |
| 21 | 20 |
| 22 namespace blink { | 21 namespace blink { |
| 23 namespace scheduler { | 22 namespace scheduler { |
| 24 class LazyNow; | 23 class LazyNow; |
| 25 class TimeDomain; | 24 class TimeDomain; |
| 26 class TaskQueueManager; | 25 class TaskQueueManager; |
| 27 | 26 |
| 28 namespace internal { | 27 namespace internal { |
| 29 class WorkQueue; | 28 class WorkQueue; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 171 |
| 173 bool should_report_when_execution_blocked() const { | 172 bool should_report_when_execution_blocked() const { |
| 174 return should_report_when_execution_blocked_; | 173 return should_report_when_execution_blocked_; |
| 175 } | 174 } |
| 176 | 175 |
| 177 // Enqueues any delayed tasks which should be run now on the | 176 // Enqueues any delayed tasks which should be run now on the |
| 178 // |delayed_work_queue|. It also schedules the next wake up with the | 177 // |delayed_work_queue|. It also schedules the next wake up with the |
| 179 // TimeDomain. Must be called from the main thread. | 178 // TimeDomain. Must be called from the main thread. |
| 180 void WakeUpForDelayedWork(LazyNow* lazy_now); | 179 void WakeUpForDelayedWork(LazyNow* lazy_now); |
| 181 | 180 |
| 182 base::TimeTicks scheduled_time_domain_wakeup() const { | |
| 183 return main_thread_only().scheduled_time_domain_wakeup; | |
| 184 } | |
| 185 | |
| 186 void set_scheduled_time_domain_wakeup( | |
| 187 base::TimeTicks scheduled_time_domain_wakeup) { | |
| 188 main_thread_only().scheduled_time_domain_wakeup = | |
| 189 scheduled_time_domain_wakeup; | |
| 190 } | |
| 191 | |
| 192 HeapHandle heap_handle() const { return main_thread_only().heap_handle; } | |
| 193 | |
| 194 void set_heap_handle(HeapHandle heap_handle) { | |
| 195 main_thread_only().heap_handle = heap_handle; | |
| 196 } | |
| 197 | |
| 198 private: | 181 private: |
| 199 friend class WorkQueue; | 182 friend class WorkQueue; |
| 200 friend class WorkQueueTest; | 183 friend class WorkQueueTest; |
| 201 | 184 |
| 202 enum class TaskType { | 185 enum class TaskType { |
| 203 NORMAL, | 186 NORMAL, |
| 204 NON_NESTABLE, | 187 NON_NESTABLE, |
| 205 }; | 188 }; |
| 206 | 189 |
| 207 struct AnyThread { | 190 struct AnyThread { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 226 // Another copy of TaskQueueManager and TimeDomain for lock-free access from | 209 // Another copy of TaskQueueManager and TimeDomain for lock-free access from |
| 227 // the main thread. See description inside struct AnyThread for details. | 210 // the main thread. See description inside struct AnyThread for details. |
| 228 TaskQueueManager* task_queue_manager; | 211 TaskQueueManager* task_queue_manager; |
| 229 TimeDomain* time_domain; | 212 TimeDomain* time_domain; |
| 230 | 213 |
| 231 std::unique_ptr<WorkQueue> delayed_work_queue; | 214 std::unique_ptr<WorkQueue> delayed_work_queue; |
| 232 std::unique_ptr<WorkQueue> immediate_work_queue; | 215 std::unique_ptr<WorkQueue> immediate_work_queue; |
| 233 std::priority_queue<Task> delayed_incoming_queue; | 216 std::priority_queue<Task> delayed_incoming_queue; |
| 234 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; | 217 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; |
| 235 size_t set_index; | 218 size_t set_index; |
| 236 HeapHandle heap_handle; | |
| 237 bool is_enabled; | 219 bool is_enabled; |
| 238 base::trace_event::BlameContext* blame_context; // Not owned. | 220 base::trace_event::BlameContext* blame_context; // Not owned. |
| 239 EnqueueOrder current_fence; | 221 EnqueueOrder current_fence; |
| 240 base::TimeTicks scheduled_time_domain_wakeup; | |
| 241 }; | 222 }; |
| 242 | 223 |
| 243 ~TaskQueueImpl() override; | 224 ~TaskQueueImpl() override; |
| 244 | 225 |
| 245 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, | 226 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, |
| 246 const base::Closure& task, | 227 const base::Closure& task, |
| 247 TaskType task_type); | 228 TaskType task_type); |
| 248 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, | 229 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, |
| 249 const base::Closure& task, | 230 const base::Closure& task, |
| 250 base::TimeDelta delay, | 231 base::TimeDelta delay, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 const bool should_report_when_execution_blocked_; | 298 const bool should_report_when_execution_blocked_; |
| 318 | 299 |
| 319 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); | 300 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); |
| 320 }; | 301 }; |
| 321 | 302 |
| 322 } // namespace internal | 303 } // namespace internal |
| 323 } // namespace scheduler | 304 } // namespace scheduler |
| 324 } // namespace blink | 305 } // namespace blink |
| 325 | 306 |
| 326 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 307 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| OLD | NEW |