[Libreoffice-commits] core.git: Branch 'feature/priorities' - 3 commits - include/vcl vcl/inc vcl/source
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@gmail.com Date: Fri Mar 6 10:39:49 2015 + 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' -voidSetTimeout( sal_uLong nTimeoutMs ); -sal_uLong GetTimeout() const { return mnTimeout; } voidSetTimeoutHdl( const Link rLink ) { maTimeoutHdl = rLink; } const Link GetTimeoutHdl() const { return maTimeoutHdl; } +voidSetTimeout( sal_uLong nTimeoutMs ); +sal_uLong GetTimeout() const { return mnTimeout; } virtual voidInvoke() SAL_OVERRIDE; voidTimeout() { 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 -boolmbNotAllTimerCalled;// 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)0x) + 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
[Libreoffice-commits] core.git: Branch 'feature/priorities' - 3 commits - include/vcl vcl/inc vcl/source
include/vcl/timer.hxx| 18 ++ vcl/inc/svdata.hxx |1 vcl/source/app/timer.cxx | 122 +++ 3 files changed, 121 insertions(+), 20 deletions(-) New commits: commit aede500f3d565299c70670694494570b36f36d6c Author: Tobias Madl tobias.madl@gmail.com Date: Wed Oct 29 07:20:41 2014 + Added starvation protection and Prio scheduling Change-Id: I23f09ac5ce56179af3ac9dcd79ec4104b09297ba diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index 7a952db..1fec77d 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -28,14 +28,14 @@ struct ImplTimerData; struct ImplSVData; enum IdlePriority : sal_Int32 { -VCL_IDLE_PRIORITY_HIGHEST = -40, // - 0ms -VCL_IDLE_PRIORITY_HIGH = -30, // - 1ms -VCL_IDLE_PRIORITY_REPAINT = -20, //- 30ms -VCL_IDLE_PRIORITY_RESIZE = -10, //- 50ms +VCL_IDLE_PRIORITY_HIGHEST = -400, // - 0ms +VCL_IDLE_PRIORITY_HIGH = -300, // - 1ms +VCL_IDLE_PRIORITY_REPAINT = -200, //- 30ms +VCL_IDLE_PRIORITY_RESIZE = -100, //- 50ms VCL_IDLE_PRIORITY_MEDIUM = 0, // - 50ms -VCL_IDLE_PRIORITY_LOW = 10, //- 100ms -VCL_IDLE_PRIORITY_LOWER = 20, // - 200ms -VCL_IDLE_PRIORITY_LOWEST = 30 // - 400ms +VCL_IDLE_PRIORITY_LOW = 100, //- 100ms +VCL_IDLE_PRIORITY_LOWER = 200, // - 200ms +VCL_IDLE_PRIORITY_LOWEST = 300 // - 400ms }; /// Base-class for timers - usually a simple, one-shot timeout diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index c1d9eed..dc74595 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -308,6 +308,7 @@ struct ImplSVData sal_uLong mnThreadCount; // is VCL MultiThread enabled ImplConfigData* mpFirstConfigData; // Zeiger auf ersten Config-Block ImplTimerData* mpFirstTimerData; // list of all running timers +ImplTimerData* mpWaitingTimerData; // sorted (prio) list of ready timers SalTimer* mpSalTimer; // interface to sal event loop/timers SalI18NImeStatus* mpImeStatus;// interface to ime status window SalSystem* mpSalSystem;// SalSystem interface diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index 8c635a2..c039de1 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -93,6 +93,7 @@ void Timer::ImplTimerCallbackProc() ImplTimerData* pTimerData; ImplTimerData* pPrioFirstTimerData; ImplTimerData* pPrevTimerData; +sal_Int32 nPrevPrio; sal_uLong nMinPeriod = MAX_TIMER_PERIOD; sal_uLong nDeltaTime; sal_uLong nTime = tools::Time::GetSystemTicks(); @@ -105,7 +106,11 @@ void Timer::ImplTimerCallbackProc() // find timer where the timer handler needs to be called pTimerData = pSVData-mpFirstTimerData; -pPrioFirstTimerData = pTimerData; +if(!pSVData-mpWaitingTimerData) +pPrioFirstTimerData = pTimerData; +else +pPrioFirstTimerData = pSVData-mpWaitingTimerData; + while ( pTimerData ) { // If the timer is not new, was not deleted, and if it is not in the timeout handler, then @@ -143,15 +148,24 @@ void Timer::ImplTimerCallbackProc() pCurrentTimer = pPrioFirstTimerData; } } + pTimerData-mpTimer-SetPriority(pTimerData-mpTimer-GetPriority() - 1); pPrioFirstTimerData = pCurrentTimer; } } pTimerData = pTimerData-mpNext; } -while(pPrioFirstTimerData pPrioFirstTimerData-mpTimer){ +if(pPrioFirstTimerData pPrioFirstTimerData-mpTimer){ +nPrevPrio = pPrioFirstTimerData-mpTimer-GetPriority(); +pSVData-mpWaitingTimerData = pPrioFirstTimerData; +} +else +pSVData-mpWaitingTimerData = NULL; + +while(pPrioFirstTimerData pPrioFirstTimerData-mpTimer pPrioFirstTimerData-mpTimer-GetPriority() == nPrevPrio){ // set new update time pPrioFirstTimerData-mnUpdateTime = nTime; +nPrevPrio = pPrioFirstTimerData-mpTimer-GetPriority(); // if no AutoTimer than stop if ( !pPrioFirstTimerData-mpTimer-mbAuto ) @@ -167,13 +181,17 @@ void Timer::ImplTimerCallbackProc() pPrioFirstTimerData-mbInTimeout = false; pPrevTimerData = pPrioFirstTimerData; pPrioFirstTimerData = pPrioFirstTimerData-mpPrioNext; +pPrevTimerData-mpNext = pPrevTimerData-mpPrioNext; pPrevTimerData-mpPrioNext = NULL; } +if(pPrevTimerData !pPrevTimerData-mpPrioNext) +pPrevTimerData-mpNext = NULL; + // determine new time sal_uLong nNewTime = tools::Time::GetSystemTicks(); pPrevTimerData = NULL; -pTimerData = pSVData-mpFirstTimerData; +pTimerData =