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) ...@@ -156,7 +156,19 @@ void Scheduler::CallbackTaskScheduling(bool ignore)
Scheduler::ProcessTaskScheduling( true ); 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 // process all pending Tasks
// if bTimer True, only handle timer // if bTimer True, only handle timer
...@@ -166,13 +178,6 @@ void Scheduler::ProcessTaskScheduling( bool bTimer ) ...@@ -166,13 +178,6 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
sal_uInt64 nTime = tools::Time::GetSystemTicks(); sal_uInt64 nTime = tools::Time::GetSystemTicks();
sal_uInt64 nMinPeriod = MaximumTimeoutMs; 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; pSchedulerData = pSVData->mpFirstSchedulerData;
while ( pSchedulerData ) while ( pSchedulerData )
{ {
...@@ -207,12 +212,15 @@ void Scheduler::ProcessTaskScheduling( bool bTimer ) ...@@ -207,12 +212,15 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
{ {
if ( pSVData->mpSalTimer ) if ( pSVData->mpSalTimer )
pSVData->mpSalTimer->Stop(); pSVData->mpSalTimer->Stop();
pSVData->mnTimerPeriod = MaximumTimeoutMs; nMinPeriod = MaximumTimeoutMs;
pSVData->mnTimerPeriod = nMinPeriod;
} }
else else
{ {
Scheduler::ImplStartTimer(nMinPeriod, true); Scheduler::ImplStartTimer(nMinPeriod, true);
} }
return nMinPeriod;
} }
void Scheduler::Start() void Scheduler::Start()
......
...@@ -477,10 +477,12 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased ...@@ -477,10 +477,12 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
sal_uInt64 nMinTimeout = 0;
if (nReleased == 0) // else thread doesn't have SolarMutex so avoid race if (nReleased == 0) // else thread doesn't have SolarMutex so avoid race
{ // Process all Tasks nMinTimeout = Scheduler::CalculateMinimumTimeout();
Scheduler::ProcessTaskScheduling(false);
} // 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 // 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) // 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 ...@@ -491,13 +493,18 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
// case only dispatch events already available // case only dispatch events already available
// do not wait for events either if the app decided that it is too busy for timers // do not wait for events either if the app decided that it is too busy for timers
// (feature added for the slideshow) // (feature added for the slideshow)
pSVData->mpDefInst->DoYield( SalYieldResult eResult =
i_bWait && !pSVData->maAppData.mbAppQuit, pSVData->mpDefInst->DoYield(
i_bAllEvents, nReleased); i_bWait && !pSVData->maAppData.mbAppQuit,
i_bAllEvents, nReleased);
pSVData->maAppData.mnDispatchLevel--; pSVData->maAppData.mnDispatchLevel--;
DBG_TESTSOLARMUTEX(); // must be locked on return from Yield DBG_TESTSOLARMUTEX(); // must be locked on return from Yield
// Process all Tasks
Scheduler::ProcessTaskScheduling(eResult == SalYieldResult::EVENT);
// flush lazy deleted objects // flush lazy deleted objects
if( pSVData->maAppData.mnDispatchLevel == 0 ) if( pSVData->maAppData.mnDispatchLevel == 0 )
vcl::LazyDelete::flush(); 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