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 @@
 
     /// 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 @@
     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 @@
     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::CallbackTaskScheduling(bool ignore)
 {
+    // this function is for the saltimer callback
     (void)ignore;
     Scheduler::ProcessTaskScheduling( true );
 }
@@ -108,12 +112,13 @@
 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 @@
     {
         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 @@
     ImplSVData* pSVData = ImplGetSVData();
     if ( !mpSchedulerData )
     {
-        // insert Idle
+        // insert Scheduler
         mpSchedulerData                = new ImplSchedulerData;
         mpSchedulerData->mpScheduler   = this;
         mpSchedulerData->mbInScheduler = false;
@@ -203,7 +210,7 @@
     }
     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 @@
     if ( mbActive )
     {
         ImplSVData* pSVData = ImplGetSVData();
-        if ( !pSVData->mnTimerUpdate && (mnTimeout < pSVData->mnTimerPeriod) )
+        if ( !pSVData->mnUpdateStack && (mnTimeout < pSVData->mnTimerPeriod) )
             Timer::ImplStartTimer( pSVData, mnTimeout );
     }
 }