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 #include "platform/scheduler/base/task_queue_impl.h" | 5 #include "platform/scheduler/base/task_queue_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 any_thread().task_queue_manager = nullptr; | 179 any_thread().task_queue_manager = nullptr; |
180 main_thread_only().task_queue_manager = nullptr; | 180 main_thread_only().task_queue_manager = nullptr; |
181 any_thread().observer = nullptr; | 181 any_thread().observer = nullptr; |
182 main_thread_only().observer = nullptr; | 182 main_thread_only().observer = nullptr; |
183 main_thread_only().delayed_incoming_queue = std::priority_queue<Task>(); | 183 main_thread_only().delayed_incoming_queue = std::priority_queue<Task>(); |
184 immediate_incoming_queue().clear(); | 184 immediate_incoming_queue().clear(); |
185 main_thread_only().immediate_work_queue.reset(); | 185 main_thread_only().immediate_work_queue.reset(); |
186 main_thread_only().delayed_work_queue.reset(); | 186 main_thread_only().delayed_work_queue.reset(); |
187 } | 187 } |
188 | 188 |
189 bool TaskQueueImpl::RunsTasksOnCurrentThread() const { | 189 bool TaskQueueImpl::RunsTasksInCurrentSequence() const { |
190 return base::PlatformThread::CurrentId() == thread_id_; | 190 return base::PlatformThread::CurrentId() == thread_id_; |
191 } | 191 } |
192 | 192 |
193 bool TaskQueueImpl::PostDelayedTask(const tracked_objects::Location& from_here, | 193 bool TaskQueueImpl::PostDelayedTask(const tracked_objects::Location& from_here, |
194 base::OnceClosure task, | 194 base::OnceClosure task, |
195 base::TimeDelta delay) { | 195 base::TimeDelta delay) { |
196 if (delay.is_zero()) | 196 if (delay.is_zero()) |
197 return PostImmediateTaskImpl(from_here, std::move(task), TaskType::NORMAL); | 197 return PostImmediateTaskImpl(from_here, std::move(task), TaskType::NORMAL); |
198 | 198 |
199 return PostDelayedTaskImpl(from_here, std::move(task), delay, | 199 return PostDelayedTaskImpl(from_here, std::move(task), delay, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 desired_run_time, sequence_number, | 348 desired_run_time, sequence_number, |
349 nestable, sequence_number); | 349 nestable, sequence_number); |
350 any_thread().task_queue_manager->DidQueueTask( | 350 any_thread().task_queue_manager->DidQueueTask( |
351 immediate_incoming_queue().back()); | 351 immediate_incoming_queue().back()); |
352 } | 352 } |
353 | 353 |
354 if (was_immediate_incoming_queue_empty) { | 354 if (was_immediate_incoming_queue_empty) { |
355 // However there's no point posting a DoWork for a blocked queue. NB we can | 355 // However there's no point posting a DoWork for a blocked queue. NB we can |
356 // only tell if it's disabled from the main thread. | 356 // only tell if it's disabled from the main thread. |
357 bool queue_is_blocked = | 357 bool queue_is_blocked = |
358 RunsTasksOnCurrentThread() && | 358 RunsTasksInCurrentSequence() && |
359 (!IsQueueEnabled() || main_thread_only().current_fence); | 359 (!IsQueueEnabled() || main_thread_only().current_fence); |
360 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( | 360 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( |
361 this, sequence_number, queue_is_blocked); | 361 this, sequence_number, queue_is_blocked); |
362 if (any_thread().observer) | 362 if (any_thread().observer) |
363 any_thread().observer->OnQueueNextWakeUpChanged(this, desired_run_time); | 363 any_thread().observer->OnQueueNextWakeUpChanged(this, desired_run_time); |
364 } | 364 } |
365 | 365 |
366 TraceQueueSize(); | 366 TraceQueueSize(); |
367 } | 367 } |
368 | 368 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 } | 905 } |
906 | 906 |
907 void TaskQueueImpl::NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up) { | 907 void TaskQueueImpl::NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up) { |
908 if (main_thread_only().observer) | 908 if (main_thread_only().observer) |
909 main_thread_only().observer->OnQueueNextWakeUpChanged(this, wake_up); | 909 main_thread_only().observer->OnQueueNextWakeUpChanged(this, wake_up); |
910 } | 910 } |
911 | 911 |
912 } // namespace internal | 912 } // namespace internal |
913 } // namespace scheduler | 913 } // namespace scheduler |
914 } // namespace blink | 914 } // namespace blink |
OLD | NEW |