Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1176)

Unified Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc

Issue 2653643002: Move has_incoming_immediate_work to the TaskQueueManager (Closed)
Patch Set: Add some tracing Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
index 0ead39ea836ca05bd5cc6686569fd6336ac270eb..8c588eab82317fd8f63173070e90c56ef62cdf2a 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
@@ -327,19 +327,17 @@ void TaskQueueImpl::PushOntoImmediateIncomingQueueLocked(
base::TimeTicks desired_run_time,
EnqueueOrder sequence_number,
bool nestable) {
- if (any_thread().immediate_incoming_queue.empty())
- any_thread().time_domain->OnQueueHasIncomingImmediateWork(this);
// If the |immediate_incoming_queue| is empty we need a DoWork posted to make
// it run.
if (any_thread().immediate_incoming_queue.empty()) {
- // There's no point posting a DoWork for a disabled queue, however we can
+ // However there's no point posting a DoWork for a disabled queue. NB we can
// only tell if it's disabled from the main thread.
- if (base::PlatformThread::CurrentId() == thread_id_) {
- if (IsQueueEnabled() && !BlockedByFenceLocked())
- any_thread().task_queue_manager->MaybeScheduleImmediateWork(FROM_HERE);
- } else {
- any_thread().task_queue_manager->MaybeScheduleImmediateWork(FROM_HERE);
- }
+ bool ensure_do_work_posted =
Sami 2017/01/24 14:52:40 To separate the concerns a bit, how about calling
alex clarke (OOO till 29th) 2017/01/24 15:28:14 I suppose task_currently_blocked?
+ !RunsTasksOnCurrentThread() ||
+ (IsQueueEnabled() && !main_thread_only().current_fence);
+ any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork(
+ this, ensure_do_work_posted);
+ any_thread().time_domain->OnQueueHasImmediateWork(this);
}
any_thread().immediate_incoming_queue.emplace_back(
posted_from, task, desired_run_time, sequence_number, nestable,
@@ -674,19 +672,23 @@ bool TaskQueueImpl::BlockedByFence() const {
main_thread_only().current_fence;
}
-bool TaskQueueImpl::BlockedByFenceLocked() const {
- if (!main_thread_only().current_fence)
+bool TaskQueueImpl::ImmediateTaskCouldRun() const {
+ if (!IsQueueEnabled())
return false;
- if (!main_thread_only().immediate_work_queue->BlockedByFence() ||
- !main_thread_only().delayed_work_queue->BlockedByFence()) {
- return false;
- }
+ if (!main_thread_only().current_fence)
+ return true;
+
+ if (!main_thread_only().immediate_work_queue->Empty())
+ return !main_thread_only().immediate_work_queue->BlockedByFence();
+ base::AutoLock lock(any_thread_lock_);
+ // If |immediate_incoming_queue| and |immediate_work_queue| are empty then any
+ // task posted is guaranteed to be blocked by the fence.
if (any_thread().immediate_incoming_queue.empty())
- return true;
+ return false;
- return any_thread().immediate_incoming_queue.front().enqueue_order() >
+ return any_thread().immediate_incoming_queue.front().enqueue_order() <
main_thread_only().current_fence;
}

Powered by Google App Engine
This is Rietveld 408576698