summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-02-07 16:58:31 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2017-07-13 12:10:24 +0200
commite613e2ebcd64bbe8a5cdc35750e49e773c5b03f4 (patch)
treec0be5ca364f86f2e3d94bb6f1c2c210507fcbe28 /vcl
parent7a1c1699a61a77d0228417da9922812c9b893b9d (diff)
Restart the system timer if it returns to early
At least on Windows our GetSystemTicks() implementation - using QueryPerformanceCounter - occasionally states, the timer returned too early, which stops processing further LO events. As a workaround we restart the timer, as it's now the only source of running the LO main loop. Probably we should use osl_getSystemTime, for measuring, which uses GetSystemTimePreciseAsFileTime, if available. Nothing states anything is monotonic, so in this regard it may be flawed too. Change-Id: I94eacd8f5bacf277a68575cc8db84653cbc49d12
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/scheduler.cxx25
1 files changed, 14 insertions, 11 deletions
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 3ad49f5844c2..0fba128404fa 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -173,17 +173,11 @@ bool Scheduler::GetDeterministicMode()
return g_bDeterministicMode;
}
-inline bool Scheduler::HasPendingTasks( const ImplSchedulerContext &rSchedCtx,
- const sal_uInt64 nTime )
-{
- return ( rSchedCtx.mbNeedsReschedule || ((rSchedCtx.mnTimerPeriod != InfiniteTimeoutMs)
- && (nTime >= rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod )) );
-}
-
bool Scheduler::HasPendingTasks()
{
- return HasPendingTasks( ImplGetSVData()->maSchedCtx,
- tools::Time::GetSystemTicks() );
+ const ImplSchedulerContext &rSchedCtx = ImplGetSVData()->maSchedCtx;
+ return ( rSchedCtx.mbNeedsReschedule || ((rSchedCtx.mnTimerPeriod != InfiniteTimeoutMs)
+ && (tools::Time::GetSystemTicks() >= rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod )) );
}
inline void Scheduler::UpdateMinPeriod( ImplSchedulerData * const pSchedulerData,
@@ -250,11 +244,20 @@ bool Scheduler::ProcessTaskScheduling()
{
ImplSVData *pSVData = ImplGetSVData();
ImplSchedulerContext &rSchedCtx = pSVData->maSchedCtx;
- sal_uInt64 nTime = tools::Time::GetSystemTicks();
- if ( pSVData->mbDeInit || !HasPendingTasks( rSchedCtx, nTime ) )
+ sal_uInt64 nTime = tools::Time::GetSystemTicks();
+ if ( pSVData->mbDeInit || InfiniteTimeoutMs == rSchedCtx.mnTimerPeriod )
return false;
rSchedCtx.mbNeedsReschedule = false;
+ if ( nTime < rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod )
+ {
+ SAL_WARN( "vcl.schedule", "we're too early - restart the timer!" );
+ UpdateSystemTimer( rSchedCtx,
+ rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod - nTime,
+ true, nTime );
+ return false;
+ }
+
ImplSchedulerData* pSchedulerData = nullptr;
ImplSchedulerData* pPrevSchedulerData = nullptr;
ImplSchedulerData *pMostUrgent = nullptr;