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

Unified Diff: Source/platform/scheduler/Scheduler.cpp

Issue 640053003: Modify the scheduler to queue idle work between idle periods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename queuedTasks to incomingTasks Created 6 years, 2 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
« no previous file with comments | « Source/platform/scheduler/Scheduler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scheduler/Scheduler.cpp
diff --git a/Source/platform/scheduler/Scheduler.cpp b/Source/platform/scheduler/Scheduler.cpp
index 8e4ea26fbf2beab4678426a881d7779c7d0afa28..96157c0b2c2feb9206bb24a8cf2a04a40062d8fb 100644
--- a/Source/platform/scheduler/Scheduler.cpp
+++ b/Source/platform/scheduler/Scheduler.cpp
@@ -139,6 +139,7 @@ void Scheduler::didCommitFrameToCompositor()
{
ASSERT(isMainThread());
m_currentFrameCommitted = true;
+ flushIncomingIdleTasks();
maybePostMainThreadPendingIdleTask();
}
@@ -157,8 +158,8 @@ void Scheduler::didRunHighPriorityTask()
void Scheduler::postIdleTaskInternal(const TraceLocation& location, const IdleTask& idleTask, const char* traceName)
{
- Locker<Mutex> lock(m_pendingIdleTasksMutex);
- m_pendingIdleTasks.append(internal::TracedIdleTask::Create(idleTask, location, traceName));
+ Locker<Mutex> lock(m_incomingIdleTasksMutex);
+ m_incomingIdleTasks.append(internal::TracedIdleTask::Create(idleTask, location, traceName));
}
void Scheduler::postTask(const TraceLocation& location, const Task& task)
@@ -200,7 +201,6 @@ bool Scheduler::maybePostMainThreadPendingIdleTask()
ASSERT(isMainThread());
TRACE_EVENT0("blink", "Scheduler::maybePostMainThreadPendingIdleTask");
if (canRunIdleTask()) {
- Locker<Mutex> lock(m_pendingIdleTasksMutex);
if (!m_pendingIdleTasks.isEmpty()) {
m_mainThread->postTask(new MainThreadPendingIdleTaskRunner());
return true;
@@ -263,18 +263,23 @@ bool Scheduler::shouldYieldForHighPriorityWork() const
bool Scheduler::maybeRunPendingIdleTask()
{
ASSERT(isMainThread());
- if (!canRunIdleTask())
+ if (!canRunIdleTask() || m_pendingIdleTasks.isEmpty())
return false;
- takeFirstPendingIdleTask()->run();
+ m_pendingIdleTasks.takeFirst()->run();
return true;
}
-PassOwnPtr<internal::TracedIdleTask> Scheduler::takeFirstPendingIdleTask()
+void Scheduler::flushIncomingIdleTasks()
{
- Locker<Mutex> lock(m_pendingIdleTasksMutex);
- ASSERT(!m_pendingIdleTasks.isEmpty());
- return m_pendingIdleTasks.takeFirst();
+ ASSERT(isMainThread());
+ Locker<Mutex> lock(m_incomingIdleTasksMutex);
Sami 2014/10/10 17:31:31 I'm trying to decide whether we should only do thi
rmcilroy 2014/10/13 11:41:19 I don't think it would make much of a difference e
+ if (m_incomingIdleTasks.isEmpty())
+ return;
+
picksi1 2014/10/13 09:38:09 Is it worth doing this empty check here? The follo
rmcilroy 2014/10/13 11:41:19 Makes sense, dropped it.
+ while (!m_incomingIdleTasks.isEmpty()) {
jochen (gone - plz use gerrit) 2014/10/13 08:09:11 nit. no { } what happens if the idle task immedia
rmcilroy 2014/10/13 11:41:19 If the idle task immediately posts a new task it w
+ m_pendingIdleTasks.append(m_incomingIdleTasks.takeFirst());
+ }
picksi1 2014/10/13 09:38:09 Is there no quick way to append the entire queue h
rmcilroy 2014/10/13 11:41:19 I couldn't find any faster append in Deque - let m
}
double Scheduler::currentFrameDeadlineForIdleTasks() const
« no previous file with comments | « Source/platform/scheduler/Scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698