Kaydet (Commit) d3cdd7ef authored tarafından Michael Meeks's avatar Michael Meeks

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
üst 5a08d3fa
......@@ -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()
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment