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

Side by Side Diff: components/scheduler/base/task_queue_impl.cc

Issue 1468443002: Reduce the number of delayed tasks on chromium run loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Weak pointer Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
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 "components/scheduler/base/task_queue_impl.h" 5 #include "components/scheduler/base/task_queue_impl.h"
6 6
7 #include "components/scheduler/base/task_queue_manager.h" 7 #include "components/scheduler/base/task_queue_manager.h"
8 #include "components/scheduler/base/task_queue_manager_delegate.h" 8 #include "components/scheduler/base/task_queue_manager_delegate.h"
9 #include "components/scheduler/base/time_domain.h" 9 #include "components/scheduler/base/time_domain.h"
10 10
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 TraceQueueSize(true); 318 TraceQueueSize(true);
319 } 319 }
320 320
321 // TODO(alexclarke): Consider merging EnqueueTaskLocked & 321 // TODO(alexclarke): Consider merging EnqueueTaskLocked &
322 // EnqueueDelayedTaskLocked. 322 // EnqueueDelayedTaskLocked.
323 void TaskQueueImpl::EnqueueDelayedTaskLocked(const Task& pending_task) { 323 void TaskQueueImpl::EnqueueDelayedTaskLocked(const Task& pending_task) {
324 if (!any_thread().task_queue_manager) 324 if (!any_thread().task_queue_manager)
325 return; 325 return;
326 if (any_thread().incoming_queue.empty()) 326 if (any_thread().incoming_queue.empty())
327 any_thread().time_domain->RegisterAsUpdatableTaskQueue(this); 327 any_thread().time_domain->RegisterAsUpdatableTaskQueue(this);
328 if (any_thread().pump_policy == PumpPolicy::AUTO &&
329 any_thread().incoming_queue.empty()) {
330 any_thread().task_queue_manager->MaybePostDoWorkOnMainRunner();
331 }
332 // TODO(alexclarke): consider std::move() when allowed. 328 // TODO(alexclarke): consider std::move() when allowed.
333 any_thread().incoming_queue.push(pending_task); 329 any_thread().incoming_queue.push(pending_task);
334 any_thread().incoming_queue.back().set_enqueue_order( 330 any_thread().incoming_queue.back().set_enqueue_order(
335 any_thread().task_queue_manager->GetNextSequenceNumber()); 331 any_thread().task_queue_manager->GetNextSequenceNumber());
336 TraceQueueSize(true); 332 TraceQueueSize(true);
337 } 333 }
338 334
339 void TaskQueueImpl::SetPumpPolicy(PumpPolicy pump_policy) { 335 void TaskQueueImpl::SetPumpPolicy(PumpPolicy pump_policy) {
340 base::AutoLock lock(any_thread_lock_); 336 base::AutoLock lock(any_thread_lock_);
341 if (pump_policy == PumpPolicy::AUTO && 337 if (pump_policy == PumpPolicy::AUTO &&
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 state->EndDictionary(); 551 state->EndDictionary();
556 } 552 }
557 553
558 size_t TaskQueueImpl::IncomingQueueSizeForTest() const { 554 size_t TaskQueueImpl::IncomingQueueSizeForTest() const {
559 base::AutoLock lock(any_thread_lock_); 555 base::AutoLock lock(any_thread_lock_);
560 return any_thread().incoming_queue.size(); 556 return any_thread().incoming_queue.size();
561 } 557 }
562 558
563 } // namespace internal 559 } // namespace internal
564 } // namespace scheduler 560 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/base/real_time_domain.cc ('k') | components/scheduler/base/task_queue_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698