зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1197152: Alternative to remove all sleep/wake functionality from Timers r=froydnj
CLOSED TREE --HG-- extra : amend_source : 8c363c570bea046904f2f9d7bf72b107012653d7
This commit is contained in:
Родитель
063ce7de72
Коммит
5e0e7e846c
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ private:
|
|||
bool mWaiting;
|
||||
bool mNotified;
|
||||
bool mSleeping;
|
||||
TimeStamp mLastTimerEventLoopRun;
|
||||
|
||||
nsTArray<nsTimerImpl*> mTimers;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче