| 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 "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/blame_context.h" | 10 #include "base/trace_event/blame_context.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 bool nestable) { | 329 bool nestable) { |
| 330 // If the |immediate_incoming_queue| is empty we need a DoWork posted to make | 330 // If the |immediate_incoming_queue| is empty we need a DoWork posted to make |
| 331 // it run. | 331 // it run. |
| 332 if (any_thread().immediate_incoming_queue.empty()) { | 332 if (any_thread().immediate_incoming_queue.empty()) { |
| 333 // However there's no point posting a DoWork for a blocked queue. NB we can | 333 // However there's no point posting a DoWork for a blocked queue. NB we can |
| 334 // only tell if it's disabled from the main thread. | 334 // only tell if it's disabled from the main thread. |
| 335 bool queue_is_blocked = | 335 bool queue_is_blocked = |
| 336 RunsTasksOnCurrentThread() && | 336 RunsTasksOnCurrentThread() && |
| 337 (!IsQueueEnabled() || main_thread_only().current_fence); | 337 (!IsQueueEnabled() || main_thread_only().current_fence); |
| 338 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( | 338 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( |
| 339 this, queue_is_blocked); | 339 this, sequence_number, queue_is_blocked); |
| 340 any_thread().time_domain->OnQueueHasImmediateWork(this); | 340 any_thread().time_domain->OnQueueHasImmediateWork(this); |
| 341 } | 341 } |
| 342 any_thread().immediate_incoming_queue.emplace_back( | 342 any_thread().immediate_incoming_queue.emplace_back( |
| 343 posted_from, task, desired_run_time, sequence_number, nestable, | 343 posted_from, task, desired_run_time, sequence_number, nestable, |
| 344 sequence_number); | 344 sequence_number); |
| 345 any_thread().task_queue_manager->DidQueueTask( | 345 any_thread().task_queue_manager->DidQueueTask( |
| 346 any_thread().immediate_incoming_queue.back()); | 346 any_thread().immediate_incoming_queue.back()); |
| 347 TraceQueueSize(true); | 347 TraceQueueSize(true); |
| 348 } | 348 } |
| 349 | 349 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 } | 671 } |
| 672 | 672 |
| 673 base::AutoLock lock(any_thread_lock_); | 673 base::AutoLock lock(any_thread_lock_); |
| 674 if (any_thread().immediate_incoming_queue.empty()) | 674 if (any_thread().immediate_incoming_queue.empty()) |
| 675 return true; | 675 return true; |
| 676 | 676 |
| 677 return any_thread().immediate_incoming_queue.front().enqueue_order() > | 677 return any_thread().immediate_incoming_queue.front().enqueue_order() > |
| 678 main_thread_only().current_fence; | 678 main_thread_only().current_fence; |
| 679 } | 679 } |
| 680 | 680 |
| 681 bool TaskQueueImpl::CouldTaskRun(EnqueueOrder enqueue_order) const { |
| 682 if (!IsQueueEnabled()) |
| 683 return false; |
| 684 |
| 685 if (!main_thread_only().current_fence) |
| 686 return true; |
| 687 |
| 688 return enqueue_order < main_thread_only().current_fence; |
| 689 } |
| 690 |
| 681 EnqueueOrder TaskQueueImpl::GetFenceForTest() const { | 691 EnqueueOrder TaskQueueImpl::GetFenceForTest() const { |
| 682 return main_thread_only().current_fence; | 692 return main_thread_only().current_fence; |
| 683 } | 693 } |
| 684 | 694 |
| 685 // static | 695 // static |
| 686 void TaskQueueImpl::QueueAsValueInto(const WTF::Deque<Task>& queue, | 696 void TaskQueueImpl::QueueAsValueInto(const WTF::Deque<Task>& queue, |
| 687 base::trace_event::TracedValue* state) { | 697 base::trace_event::TracedValue* state) { |
| 688 for (const Task& task : queue) { | 698 for (const Task& task : queue) { |
| 689 TaskAsValueInto(task, state); | 699 TaskAsValueInto(task, state); |
| 690 } | 700 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 846 |
| 837 void TaskQueueImpl::PushImmediateIncomingTaskForTest( | 847 void TaskQueueImpl::PushImmediateIncomingTaskForTest( |
| 838 TaskQueueImpl::Task&& task) { | 848 TaskQueueImpl::Task&& task) { |
| 839 base::AutoLock lock(any_thread_lock_); | 849 base::AutoLock lock(any_thread_lock_); |
| 840 any_thread().immediate_incoming_queue.push_back(std::move(task)); | 850 any_thread().immediate_incoming_queue.push_back(std::move(task)); |
| 841 } | 851 } |
| 842 | 852 |
| 843 } // namespace internal | 853 } // namespace internal |
| 844 } // namespace scheduler | 854 } // namespace scheduler |
| 845 } // namespace blink | 855 } // namespace blink |
| OLD | NEW |