Bug 1197152: Alternative to remove all sleep/wake functionality from Timers r=froydnj

CLOSED TREE
This commit is contained in:
Randell Jesup 2015-09-08 11:34:09 -04:00
parent 5678723549
commit 1dd37ea37d
2 changed files with 3 additions and 23 deletions

View File

@ -31,8 +31,7 @@ TimerThread::TimerThread() :
mShutdown(false),
mWaiting(false),
mNotified(false),
mSleeping(false),
mLastTimerEventLoopRun(TimeStamp::Now())
mSleeping(false)
{
}
@ -441,7 +440,6 @@ TimerThread::Run()
} else {
waitFor = PR_INTERVAL_NO_TIMEOUT;
TimeStamp now = TimeStamp::Now();
mLastTimerEventLoopRun = now;
nsTimerImpl* timer = nullptr;
if (!mTimers.IsEmpty()) {
@ -747,7 +745,6 @@ TimerThread::DoBeforeSleep()
{
// Mainthread
MonitorAutoLock lock(mMonitor);
mLastTimerEventLoopRun = TimeStamp::Now();
mSleeping = true;
}
@ -756,27 +753,11 @@ void
TimerThread::DoAfterSleep()
{
// Mainthread
TimeStamp now = TimeStamp::Now();
MonitorAutoLock lock(mMonitor);
// an over-estimate of time slept, usually small
TimeDuration slept = now - mLastTimerEventLoopRun;
// Adjust all old timers to expire roughly similar times in the future
// compared to when we went to sleep, by adding the time we slept to the
// target time. It's slightly possible a few will end up slightly in the
// past and fire immediately, but ordering should be preserved. All
// timers retain the exact same order (and relative times) as before
// going to sleep.
for (uint32_t i = 0; i < mTimers.Length(); i ++) {
nsTimerImpl* timer = mTimers[i];
timer->mTimeout += slept;
}
mSleeping = false;
mLastTimerEventLoopRun = now;
// Wake up the timer thread to process the updated array
// Wake up the timer thread to re-process the array to ensure the sleep delay is correct,
// and fire any expired timers (perhaps quite a few)
mNotified = true;
mMonitor.Notify();
}

View File

@ -77,7 +77,6 @@ private:
bool mWaiting;
bool mNotified;
bool mSleeping;
TimeStamp mLastTimerEventLoopRun;
nsTArray<nsTimerImpl*> mTimers;
};