mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1197152: Alternative to remove all sleep/wake functionality from Timers r=froydnj
CLOSED TREE
This commit is contained in:
parent
5678723549
commit
1dd37ea37d
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user