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

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: Drop extra {} 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') | Source/platform/scheduler/SchedulerTest.cpp » ('j') | 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..a5fd7ce7c4e45a18316a3b6dc7ff7bbba81a5af1 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,19 @@ 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);
+ while (!m_incomingIdleTasks.isEmpty())
+ m_pendingIdleTasks.append(m_incomingIdleTasks.takeFirst());
}
double Scheduler::currentFrameDeadlineForIdleTasks() const
« no previous file with comments | « Source/platform/scheduler/Scheduler.h ('k') | Source/platform/scheduler/SchedulerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698