diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-09-06 08:27:08 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-01-17 16:08:46 +0100 |
commit | 9ec3b1e1bfd38a7a26b8f22024b0d62f771fd5a5 (patch) | |
tree | c922f7cbe0688763a4fc5b69312e2cef1b48c88d /vcl | |
parent | 9e51007039770370182839846676b205f5c34c57 (diff) |
Always schedule with the same time
No need to always update the time - scheduling should be fast!
Change-Id: Ic4c01f5a5759ef4970f1385aab6ef93cd67f33b6
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/saltimer.hxx | 2 | ||||
-rw-r--r-- | vcl/source/app/idle.cxx | 2 | ||||
-rw-r--r-- | vcl/source/app/scheduler.cxx | 17 | ||||
-rw-r--r-- | vcl/source/app/timer.cxx | 26 |
4 files changed, 21 insertions, 26 deletions
diff --git a/vcl/inc/saltimer.hxx b/vcl/inc/saltimer.hxx index 9a71eace286f..72b1eb8e14fa 100644 --- a/vcl/inc/saltimer.hxx +++ b/vcl/inc/saltimer.hxx @@ -70,7 +70,7 @@ struct ImplSchedulerData void Invoke(); const char *GetDebugName() const; - static ImplSchedulerData *GetMostImportantTask( bool bTimer ); + static ImplSchedulerData *GetMostImportantTask( bool bTimerOnly, sal_uInt64 nTimeNow ); }; #endif // INCLUDED_VCL_INC_SALTIMER_HXX diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index 10a7a495a92f..faf499ed440b 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -74,7 +74,7 @@ bool Idle::IsIdle() const return true; } -sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 /* nMinPeriod */, sal_uInt64 /* nTime */ ) const +sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 /* nMinPeriod */, sal_uInt64 /* nTimeNow */ ) const { assert(false); // idles currently don't hit this. return ImmediateTimeoutMs; diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index c9aa2b1b3c2d..cc4e14ac4a1d 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -49,12 +49,11 @@ void ImplSchedulerData::Invoke() mbInScheduler = false; } -ImplSchedulerData *ImplSchedulerData::GetMostImportantTask( bool bTimerOnly ) +ImplSchedulerData *ImplSchedulerData::GetMostImportantTask( bool bTimerOnly, sal_uInt64 nTimeNow ) { ImplSVData* pSVData = ImplGetSVData(); ImplSchedulerData *pMostUrgent = nullptr; - sal_uInt64 nTimeNow = tools::Time::GetSystemTicks(); for ( ImplSchedulerData *pSchedulerData = pSVData->mpFirstSchedulerData; pSchedulerData; pSchedulerData = pSchedulerData->mpNext ) { if ( !pSchedulerData->mpScheduler || pSchedulerData->mbDelete || pSchedulerData->mbInScheduler || @@ -173,13 +172,16 @@ void Scheduler::CallbackTaskScheduling(bool) bool Scheduler::ProcessTaskScheduling( bool bTimerOnly ) { + ImplSchedulerData* pSchedulerData; + sal_uInt64 nTime = tools::Time::GetSystemTicks(); + DBG_TESTSOLARMUTEX(); - if (ImplSchedulerData * pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimerOnly)) + if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimerOnly, nTime))) { SAL_INFO("vcl.schedule", "Invoke task " << pSchedulerData->GetDebugName()); - pSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks(); + pSchedulerData->mnUpdateTime = nTime; pSchedulerData->Invoke(); return true; } @@ -243,6 +245,13 @@ sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles ) pSchedulerData->GetDebugName() << "' update min period from " << nOldMinPeriod << " to " << nMinPeriod); + assert( nMinPeriod <= nOldMinPeriod ); + if ( nMinPeriod > nOldMinPeriod ) + { + nMinPeriod = nOldMinPeriod; + SAL_WARN("vcl.schedule", + "New update min period > old period - using old"); + } } else { diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index accd92734746..aabfbb28a211 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -41,30 +41,16 @@ bool Timer::IsIdle() const return false; } -sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) const +sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const { - sal_uInt64 nDeltaTime; - //determine smallest time slot - if( mpSchedulerData->mnUpdateTime == nTime ) - { - nDeltaTime = mnTimeout; - if( nDeltaTime < nMinPeriod ) - nMinPeriod = nDeltaTime; - } + sal_uInt64 nWakeupTime = mpSchedulerData->mnUpdateTime + mnTimeout; + if( nWakeupTime <= nTimeNow ) + return ImmediateTimeoutMs; else { - nDeltaTime = mpSchedulerData->mnUpdateTime + mnTimeout; - if( nDeltaTime < nTime ) - nMinPeriod = ImmediateTimeoutMs; - else - { - nDeltaTime -= nTime; - if( nDeltaTime < nMinPeriod ) - nMinPeriod = nDeltaTime; - } + sal_uInt64 nSleepTime = nWakeupTime - nTimeNow; + return ( nSleepTime < nMinPeriod ) ? nSleepTime : nMinPeriod; } - - return nMinPeriod; } Timer::Timer(const sal_Char *pDebugName) : |