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

Tobias Madl tobias.madl.dev at gmail.com
Fri Mar 6 04:25:19 PST 2015


 include/vcl/scheduler.hxx    |   22 ++++++++----------
 include/vcl/timer.hxx        |    4 +--
 vcl/inc/svdata.hxx           |    3 --
 vcl/source/app/scheduler.cxx |   52 ++++++++++++++++++++-----------------------
 vcl/source/app/svapp.cxx     |    4 ---
 vcl/source/app/svmain.cxx    |    1 
 vcl/source/app/timer.cxx     |    6 +---
 7 files changed, 40 insertions(+), 52 deletions(-)

New commits:
commit 950d093f21a1ce42020386052aaff8c0812d57a0
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date:   Fri Mar 6 10:39:49 2015 +0000

    adapted comments and variable names
    
    Change-Id: I4f2c1d743ce2f30e8c24180b73f0716fc13b459e

diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index a999559..004e78c 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -40,10 +40,10 @@ public:
 
     /// Make it possible to associate a callback with this timer handler
     /// of course, you can also sub-class and override 'Invoke'
-    void            SetTimeout( sal_uLong nTimeoutMs );
-    sal_uLong       GetTimeout() const { return mnTimeout; }
     void            SetTimeoutHdl( const Link& rLink ) { maTimeoutHdl = rLink; }
     const Link&     GetTimeoutHdl() const { return maTimeoutHdl; }
+    void            SetTimeout( sal_uLong nTimeoutMs );
+    sal_uLong       GetTimeout() const { return mnTimeout; }
     virtual void    Invoke() SAL_OVERRIDE;
     void            Timeout() { Invoke(); }
     Timer&          operator=( const Timer& rTimer );
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 132c272..967f3df 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -317,8 +317,7 @@ struct ImplSVData
     SalSystem*              mpSalSystem;                    // SalSystem interface
     ResMgr*                 mpResMgr;                       // SV-Resource-Manager
     sal_uLong               mnTimerPeriod;                  // current timer period
-    sal_uLong               mnTimerUpdate;                  // TimerCallbackProcs on stack
-    bool                    mbNotAllTimerCalled;            // true: Timer must still be processed
+    sal_uLong               mnUpdateStack;                  // Scheduler on stack
     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/scheduler.cxx b/vcl/source/app/scheduler.cxx
index fc52b90..5a0061f 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -23,11 +23,14 @@
 #include <vcl/timer.hxx>
 #include <saltimer.hxx>
 
+#define MAX_TIMER_PERIOD    ((sal_uLong)0xFFFFFFFF)
+
 void ImplSchedulerData::Invoke()
 {
     if (mbDelete || mbInScheduler )
         return;
 
+    // prepare Scheduler Object for deletion after handling
     mpScheduler->SetDeletionFlags();
 
     // invoke it
@@ -41,20 +44,20 @@ ImplSchedulerData *ImplSchedulerData::GetMostImportantTask( bool bTimer )
     ImplSVData*     pSVData = ImplGetSVData();
     ImplSchedulerData *pMostUrgent = NULL;
 
-    for ( ImplSchedulerData *p = pSVData->mpFirstSchedulerData; p; p = p->mpNext )
+    for ( ImplSchedulerData *pSchedulerData = pSVData->mpFirstSchedulerData; pSchedulerData; pSchedulerData = pSchedulerData->mpNext )
     {
-        if ( !p->mpScheduler || p->mbDelete || p->mnUpdateStack >= pSVData->mnTimerUpdate || !p->mpScheduler->ReadyForSchedule( bTimer ) )
+        if ( !pSchedulerData->mpScheduler || pSchedulerData->mbDelete || pSchedulerData->mnUpdateStack >= pSVData->mnUpdateStack
+            || !pSchedulerData->mpScheduler->ReadyForSchedule( bTimer ) )
             continue;
         if (!pMostUrgent)
-            pMostUrgent = p;
+            pMostUrgent = pSchedulerData;
         else
         {
             // Find the highest priority.
-            // If the priority of the current idle is higher (numerical value is lower) than
-            // the priority of the most urgent, the priority of most urgent is increased and
-            // the current is the new most urgent. So starving is impossible.
-            if ( p->mpScheduler->GetPriority() < pMostUrgent->mpScheduler->GetPriority() )
-                pMostUrgent = p;
+            // If the priority of the current task is higher (numerical value is lower) than
+            // the priority of the most urgent, the current task gets the new most urgent.
+            if ( pSchedulerData->mpScheduler->GetPriority() < pMostUrgent->mpScheduler->GetPriority() )
+                pMostUrgent = pSchedulerData;
         }
     }
 
@@ -101,6 +104,7 @@ void Scheduler::ImplDeInitScheduler()
 
 void Scheduler::CallbackTaskScheduling(bool ignore)
 {
+    // this function is for the saltimer callback
     (void)ignore;
     Scheduler::ProcessTaskScheduling( true );
 }
@@ -108,12 +112,13 @@ void Scheduler::CallbackTaskScheduling(bool ignore)
 void Scheduler::ProcessTaskScheduling( bool bTimer )
 {
     // process all pending Tasks
+    // if bTimer True, only handle timer
     ImplSchedulerData* pSchedulerData = NULL;
     ImplSchedulerData* pPrevSchedulerData = NULL;
     ImplSVData*        pSVData = ImplGetSVData();
     sal_uLong          nTime = tools::Time::GetSystemTicks();
-    sal_uLong          nMinPeriod = ((sal_uLong)0xFFFFFFFF);
-    pSVData->mnTimerUpdate++;
+    sal_uLong          nMinPeriod = MAX_TIMER_PERIOD;
+    pSVData->mnUpdateStack++;
 
     if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimer)))
     {
@@ -156,15 +161,17 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
     {
         if ( pSVData->mpSalTimer )
             pSVData->mpSalTimer->Stop();
-        pSVData->mnTimerPeriod = ((sal_uLong)0xFFFFFFFF);
+        pSVData->mnTimerPeriod = MAX_TIMER_PERIOD;
     }
     else
         Timer::ImplStartTimer( pSVData, nMinPeriod );
-    pSVData->mnTimerUpdate--;
+    pSVData->mnUpdateStack--;
 }
 
 sal_uLong Scheduler::UpdateMinPeriod( sal_uLong nMinPeriod, sal_uLong nTime )
 {
+    // this period is only usefull for timer
+    // so in this implementation it' only a pass through
     (void)nTime;
     return nMinPeriod;
 }
@@ -182,7 +189,7 @@ void Scheduler::Start()
     ImplSVData* pSVData = ImplGetSVData();
     if ( !mpSchedulerData )
     {
-        // insert Idle
+        // insert Scheduler
         mpSchedulerData                = new ImplSchedulerData;
         mpSchedulerData->mpScheduler   = this;
         mpSchedulerData->mbInScheduler = false;
@@ -203,7 +210,7 @@ void Scheduler::Start()
     }
     mpSchedulerData->mbDelete      = false;
     mpSchedulerData->mnUpdateTime  = tools::Time::GetSystemTicks();
-    mpSchedulerData->mnUpdateStack = pSVData->mnTimerUpdate;
+    mpSchedulerData->mnUpdateStack = pSVData->mnUpdateStack;
 }
 
 void Scheduler::Stop()
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index ac7bb5f..b4389fe 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -22,7 +22,6 @@
 #include <saltimer.hxx>
 #include <svdata.hxx>
 #include <salinst.hxx>
-#include <vcl/scheduler.hxx>
 
 #define MAX_TIMER_PERIOD    ((sal_uLong)0xFFFFFFFF)
 
@@ -122,7 +121,7 @@ void Timer::SetTimeout( sal_uLong nNewTimeout )
     if ( mbActive )
     {
         ImplSVData* pSVData = ImplGetSVData();
-        if ( !pSVData->mnTimerUpdate && (mnTimeout < pSVData->mnTimerPeriod) )
+        if ( !pSVData->mnUpdateStack && (mnTimeout < pSVData->mnTimerPeriod) )
             Timer::ImplStartTimer( pSVData, mnTimeout );
     }
 }
commit 5f4f64d32f1225a2fbd1fa6edc2dc8941f08b74c
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date:   Fri Mar 6 10:13:53 2015 +0000

    Scheduler: removed variable priority
    
    Change-Id: I6676c1012c4321b53b6ba01ebd4bfa32d56afcf9

diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 30f2e1a..1e7b3ed 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -27,11 +27,11 @@ class Scheduler;
 struct ImplSchedulerData
 {
     ImplSchedulerData*  mpNext;      // Pointer to the next element in list
-    Scheduler*          mpScheduler;      // Pointer to VCL Idle instance
-    bool                mbDelete;    // Destroy this idle?
-    bool                mbInScheduler;    // Idle handler currently processed?
+    Scheduler*          mpScheduler;      // Pointer to VCL Scheduler instance
+    bool                mbDelete;    // Destroy this scheduler?
+    bool                mbInScheduler;    // Scheduler currently processed?
     sal_uLong           mnUpdateTime;   // Last Update Time
-    sal_uLong           mnUpdateStack;  // Update Stack on stack
+    sal_uLong           mnUpdateStack;  // Update Stack
 
     void Invoke();
 
@@ -52,9 +52,8 @@ enum class SchedulerPriority {
 class VCL_DLLPUBLIC Scheduler
 {
 protected:
-    ImplSchedulerData*  mpSchedulerData;    // Pointer to element in idle list
-    sal_Int32           miPriority;         // Idle priority ( maybe divergent to default)
-    SchedulerPriority   meDefaultPriority;  // Default idle priority
+    ImplSchedulerData*  mpSchedulerData;    // Pointer to element in scheduler list
+    SchedulerPriority   mePriority;         // Scheduler priority
     bool                mbActive;           // Currently in the scheduler
 
     friend struct ImplSchedulerData;
@@ -68,11 +67,9 @@ public:
     virtual ~Scheduler();
 
     void SetPriority( SchedulerPriority ePriority );
-    void SetSchedulingPriority( sal_Int32 iPriority );
-    sal_Int32    GetPriority() const { return miPriority; }
-    SchedulerPriority GetDefaultPriority() const { return meDefaultPriority; }
+    SchedulerPriority GetPriority() const { return mePriority; }
 
-    // Call idle handler
+    // Call handler
     virtual void    Invoke() = 0;
 
     virtual void    Start();
@@ -83,8 +80,9 @@ public:
     Scheduler&          operator=( const Scheduler& rScheduler );
     static void ImplDeInitScheduler();
 
-    /// Process all pending idle tasks ahead of time in priority order.
+    // Process one pending Timer with highhest priority
     static void CallbackTaskScheduling( bool ignore );
+    /// Process one pending task ahead of time with highhest priority.
     static void ProcessTaskScheduling( bool bTimer );
 };
 
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index ef5e1f0..fc52b90 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -28,7 +28,6 @@ void ImplSchedulerData::Invoke()
     if (mbDelete || mbInScheduler )
         return;
 
-    mpScheduler->SetSchedulingPriority(static_cast<sal_Int32>(mpScheduler->GetDefaultPriority()));
     mpScheduler->SetDeletionFlags();
 
     // invoke it
@@ -172,12 +171,7 @@ sal_uLong Scheduler::UpdateMinPeriod( sal_uLong nMinPeriod, sal_uLong nTime )
 
 void Scheduler::SetPriority( SchedulerPriority ePriority )
 {
-    meDefaultPriority = ePriority;
-}
-
-void Scheduler::SetSchedulingPriority( sal_Int32 iPriority )
-{
-    miPriority = iPriority;
+    mePriority = ePriority;
 }
 
 void Scheduler::Start()
@@ -226,8 +220,7 @@ Scheduler& Scheduler::operator=( const Scheduler& rScheduler )
         Stop();
 
     mbActive          = false;
-    miPriority        = rScheduler.miPriority;
-    meDefaultPriority = rScheduler.meDefaultPriority;
+    mePriority = rScheduler.mePriority;
 
     if ( rScheduler.IsActive() )
         Start();
@@ -237,16 +230,14 @@ Scheduler& Scheduler::operator=( const Scheduler& rScheduler )
 
 Scheduler::Scheduler():
     mpSchedulerData(NULL),
-    miPriority(static_cast<sal_Int32>(SchedulerPriority::HIGH)),
-    meDefaultPriority(SchedulerPriority::HIGH),
+    mePriority(SchedulerPriority::HIGH),
     mbActive(false)
 {
 }
 
 Scheduler::Scheduler( const Scheduler& rScheduler ):
     mpSchedulerData(NULL),
-    miPriority(rScheduler.miPriority),
-    meDefaultPriority(rScheduler.meDefaultPriority),
+    mePriority(rScheduler.mePriority),
     mbActive(false)
 {
     if ( rScheduler.IsActive() )
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 4dec9af..ac7bb5f 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -86,8 +86,7 @@ Timer::Timer() : Scheduler()
 {
     mnTimeout = 1;
     mbAuto = false;
-    miPriority= static_cast<sal_Int32>(SchedulerPriority::HIGHEST);
-    meDefaultPriority = SchedulerPriority::HIGHEST;
+    mePriority = SchedulerPriority::HIGHEST;
 }
 
 Timer::Timer( const Timer& rTimer ) : Scheduler(rTimer)
commit 1424503f7d473e80bf7a4e9f7b5da2e74fd20381
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date:   Fri Mar 6 09:07:06 2015 +0100

    Timer/Idle: wipe out old functionality
    
    Change-Id: Id50533bc52f36d2daf31bfda4fabfb6d126df4b9

diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 0064ec0..7da6b63 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -342,10 +342,6 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
 {
     ImplSVData* pSVData = ImplGetSVData();
 
-    // run timers that have timed out
-    //while ( pSVData->mbNotAllTimerCalled )
-    //    Timer::ImplTimerCallbackProc();
-
     //Process all Tasks
     Scheduler::ProcessTaskScheduling(false);
 
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 43f76be..9d59eac6 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -387,7 +387,6 @@ void DeInitVCL()
 
     if ( pSVData->maAppData.mpIdleMgr )
         delete pSVData->maAppData.mpIdleMgr;
-    //Timer::ImplDeInitTimer();
     Scheduler::ImplDeInitScheduler();
 
     if ( pSVData->maWinData.mpMsgBoxImgList )


More information about the Libreoffice-commits mailing list