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

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

Issue 2258133002: [scheduler] Implement time-based cpu throttling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed similarity 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 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 "platform/scheduler/base/task_queue_impl.h" 5 #include "platform/scheduler/base/task_queue_impl.h"
6 6
7 #include "base/trace_event/blame_context.h" 7 #include "base/trace_event/blame_context.h"
8 #include "platform/scheduler/base/task_queue_manager.h" 8 #include "platform/scheduler/base/task_queue_manager.h"
9 #include "platform/scheduler/base/task_queue_manager_delegate.h" 9 #include "platform/scheduler/base/task_queue_manager_delegate.h"
10 #include "platform/scheduler/base/time_domain.h" 10 #include "platform/scheduler/base/time_domain.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 main_thread_only().delayed_incoming_queue.begin()->delayed_run_time <= 526 main_thread_only().delayed_incoming_queue.begin()->delayed_run_time <=
527 main_thread_only().time_domain->CreateLazyNow().Now()) { 527 main_thread_only().time_domain->CreateLazyNow().Now()) {
528 return true; 528 return true;
529 } 529 }
530 530
531 // Finally tasks on |immediate_incoming_queue| count as immediate work. 531 // Finally tasks on |immediate_incoming_queue| count as immediate work.
532 base::AutoLock lock(any_thread_lock_); 532 base::AutoLock lock(any_thread_lock_);
533 return !any_thread().immediate_incoming_queue.empty(); 533 return !any_thread().immediate_incoming_queue.empty();
534 } 534 }
535 535
536 bool TaskQueueImpl::NextScheduledWakeUp(base::TimeTicks* wakeup) {
537 LazyNow lazy_now = main_thread_only().time_domain->CreateLazyNow();
538 MoveReadyDelayedTasksToDelayedWorkQueue(&lazy_now);
539
540 if (main_thread_only().delayed_incoming_queue.empty())
541 return false;
542
543 if (wakeup) {
alex clarke (OOO till 29th) 2016/09/07 15:13:07 I don't think we should allow |wakeup| to be null.
altimin 2016/09/09 15:43:57 Done.
544 *wakeup =
545 main_thread_only().delayed_incoming_queue.begin()->delayed_run_time;
546 }
547 return true;
548 }
549
536 void TaskQueueImpl::MoveReadyDelayedTasksToDelayedWorkQueue(LazyNow* lazy_now) { 550 void TaskQueueImpl::MoveReadyDelayedTasksToDelayedWorkQueue(LazyNow* lazy_now) {
537 // Enqueue all delayed tasks that should be running now. 551 // Enqueue all delayed tasks that should be running now.
538 while (!main_thread_only().delayed_incoming_queue.empty()) { 552 while (!main_thread_only().delayed_incoming_queue.empty()) {
539 DelayedRunTimeQueue::iterator next_task = 553 DelayedRunTimeQueue::iterator next_task =
540 main_thread_only().delayed_incoming_queue.begin(); 554 main_thread_only().delayed_incoming_queue.begin();
541 if (next_task->delayed_run_time > lazy_now->Now()) 555 if (next_task->delayed_run_time > lazy_now->Now())
542 break; 556 break;
543 // TODO(alexclarke): Use extract() when C++17 is allowed. 557 // TODO(alexclarke): Use extract() when C++17 is allowed.
544 Task& task = const_cast<Task&>(*next_task); 558 Task& task = const_cast<Task&>(*next_task);
545 task.set_enqueue_order( 559 task.set_enqueue_order(
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 state->SetBoolean("is_high_res", task.is_high_res); 871 state->SetBoolean("is_high_res", task.is_high_res);
858 state->SetDouble( 872 state->SetDouble(
859 "delayed_run_time", 873 "delayed_run_time",
860 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); 874 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L);
861 state->EndDictionary(); 875 state->EndDictionary();
862 } 876 }
863 877
864 } // namespace internal 878 } // namespace internal
865 } // namespace scheduler 879 } // namespace scheduler
866 } // namespace blink 880 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698