summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-01-29 17:12:25 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2017-07-13 12:10:28 +0200
commit11ffb51b758cd18a2c61d4bfa694f9f031ecd096 (patch)
tree4ff9890da8805fa5a6a15ab3243eaa556f9ac5d8 /vcl
parentb4cc0f2d3fb9cc85e5ea7b157ec35b01c1868d50 (diff)
Drop Task::ReadyForSchedule
All relevant information is also provided by UpdateMinPeriod and the calculations were even duplicated. This also includes dropping Scheduler::UpdateMinPeriod, as this is now reduced to a simple comparison and assignment, as we simply ignore larger returned sleep times. Change-Id: I13852e3e63daead451bf7fcb98be9b1d44bd7abd
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/idle.cxx5
-rw-r--r--vcl/source/app/scheduler.cxx31
-rw-r--r--vcl/source/app/timer.cxx16
3 files changed, 15 insertions, 37 deletions
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index 4cbd3f8c0ed6..78c114801868 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -55,11 +55,6 @@ void Idle::Start()
Task::StartTimer(nPeriod);
}
-bool Idle::ReadyForSchedule( sal_uInt64 /* nTimeNow */ ) const
-{
- return true;
-}
-
sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 /* nMinPeriod */, sal_uInt64 /* nTimeNow */ ) const
{
return Scheduler::ImmediateTimeoutMs;
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index d97233cad096..8e5031a3e527 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -172,19 +172,6 @@ bool Scheduler::GetDeterministicMode()
return g_bDeterministicMode;
}
-inline void Scheduler::UpdateMinPeriod( ImplSchedulerData * const pSchedulerData,
- const sal_uInt64 nTime, sal_uInt64 &nMinPeriod )
-{
- if ( nMinPeriod > ImmediateTimeoutMs )
- {
- sal_uInt64 nCurPeriod = nMinPeriod;
- nMinPeriod = pSchedulerData->mpTask->UpdateMinPeriod( nCurPeriod, nTime );
- assert( nMinPeriod <= nCurPeriod );
- if ( nCurPeriod < nMinPeriod )
- nMinPeriod = nCurPeriod;
- }
-}
-
inline void Scheduler::UpdateSystemTimer( ImplSchedulerContext &rSchedCtx,
const sal_uInt64 nMinPeriod,
const bool bForce, const sal_uInt64 nTime )
@@ -254,6 +241,8 @@ bool Scheduler::ProcessTaskScheduling()
ImplSchedulerData *pMostUrgent = nullptr;
ImplSchedulerData *pPrevMostUrgent = nullptr;
sal_uInt64 nMinPeriod = InfiniteTimeoutMs;
+ sal_uInt64 nMostUrgentPeriod = InfiniteTimeoutMs;
+ sal_uInt64 nReadyPeriod = InfiniteTimeoutMs;
DBG_TESTSOLARMUTEX();
@@ -298,16 +287,18 @@ bool Scheduler::ProcessTaskScheduling()
goto next_entry;
// skip ready tasks with lower priority than the most urgent (numerical lower is higher)
- if ( pSchedulerData->mpTask->ReadyForSchedule( nTime ) &&
+ nReadyPeriod = pSchedulerData->mpTask->UpdateMinPeriod( nMinPeriod, nTime );
+ if ( ImmediateTimeoutMs == nReadyPeriod &&
(!pMostUrgent || (pSchedulerData->mpTask->GetPriority() < pMostUrgent->mpTask->GetPriority())) )
{
- if ( pMostUrgent )
- UpdateMinPeriod( pMostUrgent, nTime, nMinPeriod );
+ if ( pMostUrgent && nMinPeriod > nMostUrgentPeriod )
+ nMinPeriod = nMostUrgentPeriod;
pPrevMostUrgent = pPrevSchedulerData;
pMostUrgent = pSchedulerData;
+ nMostUrgentPeriod = nReadyPeriod;
}
- else
- UpdateMinPeriod( pSchedulerData, nTime, nMinPeriod );
+ else if ( nMinPeriod > nReadyPeriod )
+ nMinPeriod = nReadyPeriod;
next_entry:
pPrevSchedulerData = pSchedulerData;
@@ -360,7 +351,9 @@ next_entry:
if ( pMostUrgent->mpTask && pMostUrgent->mpTask->IsActive() )
{
pMostUrgent->mnUpdateTime = nTime;
- UpdateMinPeriod( pMostUrgent, nTime, nMinPeriod );
+ nReadyPeriod = pMostUrgent->mpTask->UpdateMinPeriod( nMinPeriod, nTime );
+ if ( nMinPeriod > nReadyPeriod )
+ nMinPeriod = nReadyPeriod;
UpdateSystemTimer( rSchedCtx, nMinPeriod, false, nTime );
}
}
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 18796806a318..6cba9e2f2b2f 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -30,21 +30,11 @@ void Timer::SetDeletionFlags()
Task::SetDeletionFlags();
}
-bool Timer::ReadyForSchedule( sal_uInt64 nTimeNow ) const
-{
- return (GetSchedulerData()->mnUpdateTime + mnTimeout) <= nTimeNow;
-}
-
-sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const
+sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64, sal_uInt64 nTimeNow ) const
{
sal_uInt64 nWakeupTime = GetSchedulerData()->mnUpdateTime + mnTimeout;
- if( nWakeupTime <= nTimeNow )
- return Scheduler::ImmediateTimeoutMs;
- else
- {
- sal_uInt64 nSleepTime = nWakeupTime - nTimeNow;
- return ( nSleepTime < nMinPeriod ) ? nSleepTime : nMinPeriod;
- }
+ return ( nWakeupTime <= nTimeNow )
+ ? Scheduler::ImmediateTimeoutMs : nWakeupTime - nTimeNow;
}
Timer::Timer( bool bAuto, const sal_Char *pDebugName )