[Libreoffice-commits] core.git: vcl/source

Michael Meeks michael.meeks at collabora.com
Tue Nov 24 04:50:26 PST 2015


 vcl/source/app/scheduler.cxx |   26 +++++++++++++++++---------
 vcl/source/app/svapp.cxx     |   19 +++++++++++++------
 2 files changed, 30 insertions(+), 15 deletions(-)

New commits:
commit d3cdd7efca82130c2c42e3062b5ab244461ce15c
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Nov 24 10:19:11 2015 +0000

    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

diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index a1f559d..b5e64e2 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 f2df467..734b5de 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();


More information about the Libreoffice-commits mailing list