[Libreoffice-commits] core.git: Branch 'feature/priorities' - include/vcl vcl/inc vcl/source

Tobias Madl tobias.madl.dev at gmail.com
Mon Jan 19 05:09:26 PST 2015


 include/vcl/timer.hxx    |    1 +
 vcl/inc/svdata.hxx       |    1 -
 vcl/source/app/idle.cxx  |   10 +---------
 vcl/source/app/svapp.cxx |    9 +++------
 vcl/source/app/timer.cxx |   41 +++++++++++++++--------------------------
 5 files changed, 20 insertions(+), 42 deletions(-)

New commits:
commit 6168c160f89887d90c3b969e99b09d847f60140e
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date:   Mon Jan 19 13:08:26 2015 +0000

    Optimized Timer/Idle code
    
    Change-Id: I285bd632faba5a29a770404d6967f4faf7667b16

diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index 3aca8e5..635a045 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -63,6 +63,7 @@ public:
     static void ImplDeInitTimer();
     static void ImplTimerCallbackProc();
     static bool TimerReady();
+    static bool CheckExpiredTimer(const bool bDoInvoke);
 };
 
 /// An auto-timer is a multi-shot timer re-emitting itself at
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index fc49591..b227173 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -320,7 +320,6 @@ struct ImplSVData
     sal_uLong               mnTimerPeriod;                  // current timer period
     sal_uLong               mnTimerUpdate;                  // TimerCallbackProcs on stack
     bool                    mbNotAllTimerCalled;            // true: Timer must still be processed
-    bool                    mbNoCallTimer;                  // true: No Timeout calls
     ImplSVAppData           maAppData;                      // indepen data for class Application
     ImplSVGDIData           maGDIData;                      // indepen data for Output classes
     ImplSVWinData           maWinData;                      // indepen data for Windows classes
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index 74f0eaf..c3e24e1 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -185,7 +185,6 @@ void Idle::Start()
         // insert timer and start
         mpIdleData = new ImplIdleData;
         mpIdleData->mpIdle        = this;
-        mpIdleData->mbDelete       = false;
         mpIdleData->mbInIdle    = false;
 
         // insert last due to SFX!
@@ -202,14 +201,7 @@ void Idle::Start()
         else
             pSVData->mpFirstIdleData = mpIdleData;
     }
-    else if( !mpIdleData->mpIdle ) // TODO: remove when guilty found
-    {
-        OSL_FAIL( "Idle::Start() on a destroyed Idle!" );
-    }
-    else
-    {
-        mpIdleData->mbDelete        = false;
-    }
+    mpIdleData->mbDelete        = false;
 }
 
 void Idle::Stop()
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index fa97a4f..0dcdee9 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -343,11 +343,8 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
     ImplSVData* pSVData = ImplGetSVData();
 
     // run timers that have timed out
-    if ( !pSVData->mbNoCallTimer )
-    {
-        while ( pSVData->mbNotAllTimerCalled )
-            Timer::ImplTimerCallbackProc();
-    }
+    while ( pSVData->mbNotAllTimerCalled )
+        Timer::ImplTimerCallbackProc();
 
     //Process all idles
     Idle::Idle::ProcessAllIdleHandlers();
@@ -368,7 +365,7 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
 
     // the system timer events will not necessarily come in non waiting mode
     // e.g. on OS X; need to trigger timer checks manually
-    if( pSVData->maAppData.mbNoYield && !pSVData->mbNoCallTimer )
+    if( pSVData->maAppData.mbNoYield )
     {
         do
         {
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 4adc8e8..ff7233c 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -117,33 +117,10 @@ void Timer::ImplTimerCallbackProc()
     sal_uLong       nDeltaTime;
     sal_uLong       nTime = tools::Time::GetSystemTicks();
 
-    if ( pSVData->mbNoCallTimer )
-        return;
-
     pSVData->mnTimerUpdate++;
     pSVData->mbNotAllTimerCalled = true;
 
-    // find timer where the timer handler needs to be called
-    pTimerData = pSVData->mpFirstTimerData;
-    while ( pTimerData )
-    {
-        // If the timer is not new, was not deleted, and if it is not in the timeout handler, then
-        // call the handler as soon as the time is up.
-        if ( (pTimerData->mnTimerUpdate < pSVData->mnTimerUpdate) &&
-             !pTimerData->mbDelete && !pTimerData->mbInTimeout)
-        {
-            // time has expired
-            if ( pTimerData->GetDeadline() <= nTime )
-            {
-                // set new update time
-                pTimerData->mnUpdateTime = nTime;
-
-                pTimerData->Invoke();
-            }
-        }
-
-        pTimerData = pTimerData->mpNext;
-    }
+    Timer::CheckExpiredTimer(true);
 
     // determine new time
     sal_uLong nNewTime = tools::Time::GetSystemTicks();
@@ -212,10 +189,16 @@ void Timer::ImplTimerCallbackProc()
 
 bool Timer::TimerReady()
 {
+    return Timer::CheckExpiredTimer(false);
+}
+
+bool Timer::CheckExpiredTimer(bool bDoInvoke)
+{
 // find timer where the timer handler needs to be called
     ImplSVData*     pSVData = ImplGetSVData();
     ImplTimerData* pTimerData = pSVData->mpFirstTimerData;
     sal_uLong       nTime = tools::Time::GetSystemTicks();
+    bool            timerExpired = false;
     while ( pTimerData )
     {
         // If the timer is not new, was not deleted, and if it is not in the timeout handler, then
@@ -226,13 +209,19 @@ bool Timer::TimerReady()
             // time has expired
             if ( pTimerData->GetDeadline() <= nTime )
             {
-               return true;
+                if(bDoInvoke)
+                {
+                    //Set new update Timer
+                    pTimerData->mnUpdateTime = nTime;
+                    pTimerData->Invoke();
+                }
+                timerExpired = true;
             }
         }
 
         pTimerData = pTimerData->mpNext;
     }
-    return false;
+    return timerExpired;
 }
 
 Timer::Timer():


More information about the Libreoffice-commits mailing list