summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Madl <tobias.madl.dev@gmail.com>2015-03-06 10:39:49 +0000
committerTobias Madl <tobias.madl.dev@gmail.com>2015-03-06 12:24:12 +0000
commit950d093f21a1ce42020386052aaff8c0812d57a0 (patch)
treed7f4c67181a64055111160bf0ac9f2de4a594b67
parentScheduler: removed variable priority (diff)
downloadcore-feature/priorities.tar.gz
core-feature/priorities.zip
adapted comments and variable names feature/priorities
Change-Id: I4f2c1d743ce2f30e8c24180b73f0716fc13b459e
-rw-r--r--include/vcl/timer.hxx4
-rw-r--r--vcl/inc/svdata.hxx3
-rw-r--r--vcl/source/app/scheduler.cxx35
-rw-r--r--vcl/source/app/timer.cxx3
4 files changed, 25 insertions, 20 deletions
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index a999559d5ff6..004e78c9a7e4 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 132c27289b9f..967f3dfdce23 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 fc52b905426c..5a0061f4cccf 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 ac7bb5ffd306..b4389fe8dbc4 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 );
}
}