diff options
author | Tobias Madl <tobias.madl.dev@gmail.com> | 2015-01-19 13:08:26 +0000 |
---|---|---|
committer | Tobias Madl <tobias.madl.dev@gmail.com> | 2015-03-06 12:27:07 +0000 |
commit | 3f64e7c16a63fdc330e108cd74182c615d229bb6 (patch) | |
tree | a7d4605d09270adc55162070ff9248a63e4d869c /vcl/source/app/timer.cxx | |
parent | 4c3cea26b84cc70a67ff4eda99b842d8786a3628 (diff) |
Optimized Timer/Idle code
Change-Id: I285bd632faba5a29a770404d6967f4faf7667b16
Diffstat (limited to 'vcl/source/app/timer.cxx')
-rw-r--r-- | vcl/source/app/timer.cxx | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index 47c7c372cd47..97ab45c9fbd9 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -117,33 +117,10 @@ void Timer::ImplTimerCallbackProc( bool idle ) sal_uLong nDeltaTime; sal_uLong nTime = tools::Time::GetSystemTicks(); - if ( pSVData->mbNoCallTimer ) - return; - pSVData->mnTimerUpdate++; pSVData->mbNotAllTimerCalled = true; - // find timer where the timer handler needs to be called - pTimerData = pSVData->mpFirstTimerData; - while ( pTimerData ) - { - // If the timer is not new, was not deleted, and if it is not in the timeout handler, then - // call the handler as soon as the time is up. - if ( (pTimerData->mnTimerUpdate < pSVData->mnTimerUpdate) && - !pTimerData->mbDelete && !pTimerData->mbInTimeout) - { - // time has expired - if ( pTimerData->GetDeadline() <= nTime ) - { - // set new update time - pTimerData->mnUpdateTime = nTime; - - pTimerData->Invoke(); - } - } - - pTimerData = pTimerData->mpNext; - } + Timer::CheckExpiredTimer(true); // determine new time sal_uLong nNewTime = tools::Time::GetSystemTicks(); @@ -212,10 +189,16 @@ void Timer::ImplTimerCallbackProc( bool idle ) bool Timer::TimerReady() { + return Timer::CheckExpiredTimer(false); +} + +bool Timer::CheckExpiredTimer(bool bDoInvoke) +{ // find timer where the timer handler needs to be called ImplSVData* pSVData = ImplGetSVData(); ImplTimerData* pTimerData = pSVData->mpFirstTimerData; sal_uLong nTime = tools::Time::GetSystemTicks(); + bool timerExpired = false; while ( pTimerData ) { // If the timer is not new, was not deleted, and if it is not in the timeout handler, then @@ -226,13 +209,19 @@ bool Timer::TimerReady() // time has expired if ( pTimerData->GetDeadline() <= nTime ) { - return true; + if(bDoInvoke) + { + //Set new update Timer + pTimerData->mnUpdateTime = nTime; + pTimerData->Invoke(); + } + timerExpired = true; } } pTimerData = pTimerData->mpNext; } - return false; + return timerExpired; } Timer::Timer(): |