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

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

Issue 2319053004: [Reland] Make canceling Timers fast. (Closed)
Patch Set: Rebased Created 4 years, 3 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/time_domain.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc b/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
index 5837384e776dbb4f8e12d192a063927f9f2c2550..3093132d23a9c932bd99b8be8d4787800dfeca79 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
@@ -159,14 +159,16 @@ void TimeDomain::UpdateWorkQueues(LazyNow lazy_now) {
MoveNewlyUpdatableQueuesIntoUpdatableQueueSet();
- auto iter = updatable_queue_set_.begin();
+ std::set<internal::TaskQueueImpl*>::iterator iter =
+ updatable_queue_set_.begin();
while (iter != updatable_queue_set_.end()) {
- internal::TaskQueueImpl* queue = *iter++;
- // NOTE Update work queue may erase itself from |updatable_queue_set_|.
- // This is fine, erasing an element won't invalidate any interator, as long
- // as the iterator isn't the element being delated.
- if (queue->immediate_work_queue()->Empty())
- queue->UpdateImmediateWorkQueue();
+ std::set<internal::TaskQueueImpl*>::iterator queue_it = iter++;
+ internal::TaskQueueImpl* queue = *queue_it;
+
+ // Update the queue and remove from the set if subsequent updates are not
+ // required.
+ if (!queue->MaybeUpdateImmediateWorkQueues())
+ updatable_queue_set_.erase(queue_it);
}
}
@@ -196,7 +198,7 @@ void TimeDomain::WakeupReadyDelayedQueues(LazyNow* lazy_now) {
// in which EnqueueTaskLocks is called is respected when choosing which
// queue to execute a task from.
if (dedup_set.insert(next_wakeup->second).second) {
- next_wakeup->second->UpdateDelayedWorkQueue(lazy_now);
+ next_wakeup->second->MoveReadyDelayedTasksToDelayedWorkQueue(lazy_now);
}
delayed_wakeup_multimap_.erase(next_wakeup);
}

Powered by Google App Engine
This is Rietveld 408576698