summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-11-24 10:19:11 +0000
committerMichael Meeks <michael.meeks@collabora.com>2015-11-24 12:57:22 +0000
commitd3cdd7efca82130c2c42e3062b5ab244461ce15c (patch)
tree340bd40fd80f4fcf5c446ec4c270e2a9a9c2e211
parent5a08d3fa47cfcfe89ccefd5023c95f6b3775ab4f (diff)
vcl: scheduler - split timeout calculation from idle invocation.
This moves us towards unifying timeouts, events, idle handlers leaving only the OS main-loop integration in the backends. Change-Id: Iebfb0db21777d8018b33f216b13acb4ea2068659
-rw-r--r--vcl/source/app/scheduler.cxx26
-rw-r--r--vcl/source/app/svapp.cxx19
2 files changed, 30 insertions, 15 deletions
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index a1f559daf08d..b5e64e243801 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -156,7 +156,19 @@ void Scheduler::CallbackTaskScheduling(bool ignore)
Scheduler::ProcessTaskScheduling( true );
}
-void Scheduler::ProcessTaskScheduling( bool bTimer )
+void Scheduler::ProcessTaskScheduling( bool bTimerOnly )
+{
+ ImplSchedulerData* pSchedulerData;
+
+ // tdf#91727 - NB. bTimerOnly is ultimately not used
+ if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimerOnly)))
+ {
+ pSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
+ pSchedulerData->Invoke();
+ }
+}
+
+sal_uInt64 Scheduler::CalculateMinimumTimeout()
{
// process all pending Tasks
// if bTimer True, only handle timer
@@ -166,13 +178,6 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
sal_uInt64 nTime = tools::Time::GetSystemTicks();
sal_uInt64 nMinPeriod = MaximumTimeoutMs;
- // tdf#91727 - NB. bTimer is ultimately not used
- if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimer)))
- {
- pSchedulerData->mnUpdateTime = nTime;
- pSchedulerData->Invoke();
- }
-
pSchedulerData = pSVData->mpFirstSchedulerData;
while ( pSchedulerData )
{
@@ -207,12 +212,15 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
{
if ( pSVData->mpSalTimer )
pSVData->mpSalTimer->Stop();
- pSVData->mnTimerPeriod = MaximumTimeoutMs;
+ nMinPeriod = MaximumTimeoutMs;
+ pSVData->mnTimerPeriod = nMinPeriod;
}
else
{
Scheduler::ImplStartTimer(nMinPeriod, true);
}
+
+ return nMinPeriod;
}
void Scheduler::Start()
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index f2df4673598a..734b5def9f1f 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -477,10 +477,12 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
{
ImplSVData* pSVData = ImplGetSVData();
+ sal_uInt64 nMinTimeout = 0;
if (nReleased == 0) // else thread doesn't have SolarMutex so avoid race
- { // Process all Tasks
- Scheduler::ProcessTaskScheduling(false);
- }
+ nMinTimeout = Scheduler::CalculateMinimumTimeout();
+
+ // FIXME: should use returned value as param to DoYield
+ (void)nMinTimeout;
// TODO: there's a data race here on WNT only because ImplYield may be
// called without SolarMutex; if we can get rid of LazyDelete (with VclPtr)
@@ -491,13 +493,18 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
// case only dispatch events already available
// do not wait for events either if the app decided that it is too busy for timers
// (feature added for the slideshow)
- pSVData->mpDefInst->DoYield(
- i_bWait && !pSVData->maAppData.mbAppQuit,
- i_bAllEvents, nReleased);
+ SalYieldResult eResult =
+ pSVData->mpDefInst->DoYield(
+ i_bWait && !pSVData->maAppData.mbAppQuit,
+ i_bAllEvents, nReleased);
+
pSVData->maAppData.mnDispatchLevel--;
DBG_TESTSOLARMUTEX(); // must be locked on return from Yield
+ // Process all Tasks
+ Scheduler::ProcessTaskScheduling(eResult == SalYieldResult::EVENT);
+
// flush lazy deleted objects
if( pSVData->maAppData.mnDispatchLevel == 0 )
vcl::LazyDelete::flush();