Chromium Code Reviews| 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 |