[Libreoffice-commits] core.git: Branch 'feature/priorities' - vcl/inc vcl/source
Tobias Madl
tobias.madl.dev at gmail.com
Wed Oct 29 03:37:31 PDT 2014
vcl/inc/svdata.hxx | 1
vcl/source/app/timer.cxx | 56 ++++++++++++++++++++---------------------------
2 files changed, 24 insertions(+), 33 deletions(-)
New commits:
commit 4e08ce00d4f1df57edf1e9fed8d05ba854156e9a
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date: Wed Oct 29 10:36:21 2014 +0000
Working starvation protection and prio scheduling
Change-Id: I9434fd2fdfad5f54021325648c547a9634d6b291
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index dc74595..c1d9eed 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -308,7 +308,6 @@ 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 c039de1..894fb7a 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -97,19 +97,15 @@ void Timer::ImplTimerCallbackProc()
sal_uLong nMinPeriod = MAX_TIMER_PERIOD;
sal_uLong nDeltaTime;
sal_uLong nTime = tools::Time::GetSystemTicks();
+ bool bAllTimerCalled = true;
if ( pSVData->mbNoCallTimer )
return;
pSVData->mnTimerUpdate++;
pSVData->mbNotAllTimerCalled = true;
-
- // find timer where the timer handler needs to be called
pTimerData = pSVData->mpFirstTimerData;
- if(!pSVData->mpWaitingTimerData)
- pPrioFirstTimerData = pTimerData;
- else
- pPrioFirstTimerData = pSVData->mpWaitingTimerData;
+ pPrioFirstTimerData = pTimerData;
while ( pTimerData )
{
@@ -155,12 +151,8 @@ void Timer::ImplTimerCallbackProc()
pTimerData = pTimerData->mpNext;
}
- if(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
@@ -181,17 +173,20 @@ 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;
+ while(pPrioFirstTimerData && pPrioFirstTimerData->mpTimer){
+ pPrevTimerData = pPrioFirstTimerData;
+ pPrioFirstTimerData = pPrioFirstTimerData->mpPrioNext;
+ pPrevTimerData->mpPrioNext = NULL;
+ bAllTimerCalled = false;
+ }
// determine new time
sal_uLong nNewTime = tools::Time::GetSystemTicks();
pPrevTimerData = NULL;
- pTimerData = pSVData->mpWaitingTimerData;
+ pTimerData = pSVData->mpFirstTimerData;
while ( pTimerData )
{
// ignore if timer is still in timeout handler
@@ -238,15 +233,10 @@ void Timer::ImplTimerCallbackProc()
pPrevTimerData = pTimerData;
pTimerData = pTimerData->mpNext;
}
- }
-
- if(pPrioFirstTimerData && pPrioFirstTimerData->mpTimer)
- pSVData->mpWaitingTimerData = pPrioFirstTimerData;
- else
- pSVData->mpWaitingTimerData = NULL;
+ }
// delete clock if no more timers available
- if ( !pSVData->mpFirstTimerData && !pSVData->mpWaitingTimerData )
+ if ( !pSVData->mpFirstTimerData )
{
pSVData->mpSalTimer->Stop();
pSVData->mnTimerPeriod = MAX_TIMER_PERIOD;
@@ -254,16 +244,16 @@ void Timer::ImplTimerCallbackProc()
else
ImplStartTimer( pSVData, nMinPeriod );
- if(!pSVData->mpWaitingTimerData){
- pSVData->mnTimerUpdate--;
+ pSVData->mnTimerUpdate--;
+ if(bAllTimerCalled)
pSVData->mbNotAllTimerCalled = false;
- }
}
Timer::Timer():
mpTimerData(NULL),
mnTimeout(1),
- mnPriority(0),
+ mnPriority(VCL_IDLE_PRIORITY_HIGH),
+ mnDefaultPriority(VCL_IDLE_PRIORITY_HIGH),
mbActive(false),
mbAuto(false)
{
@@ -273,6 +263,7 @@ Timer::Timer( const Timer& rTimer ):
mpTimerData(NULL),
mnTimeout(rTimer.mnTimeout),
mnPriority(rTimer.mnPriority),
+ mnDefaultPriority(rTimer.mnDefaultPriority),
mbActive(false),
mbAuto(false),
maTimeoutHdl(rTimer.maTimeoutHdl)
@@ -301,17 +292,17 @@ void Timer::SetTimeout( sal_uLong nNewTimeout)
if(nNewTimeout==0)
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_HIGHEST;
- if(nNewTimeout==1)
+ else if(nNewTimeout==1)
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_HIGH;
- if(nNewTimeout > 1 && nNewTimeout<=30)
+ else if(nNewTimeout > 1 && nNewTimeout<=30)
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_REPAINT;
- if(nNewTimeout > 30 && nNewTimeout<=50)
+ else if(nNewTimeout > 30 && nNewTimeout<=50)
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_RESIZE;
- if(nNewTimeout > 50 && nNewTimeout<=100)
+ else if(nNewTimeout > 50 && nNewTimeout<=100)
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_MEDIUM;
- if(nNewTimeout > 100 && nNewTimeout<=200)
+ else if(nNewTimeout > 100 && nNewTimeout<=200)
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_LOW;
- if(nNewTimeout > 200 && nNewTimeout<=400)
+ else if(nNewTimeout > 200 && nNewTimeout<=400)
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_LOWER;
else
mnPriority = IdlePriority::VCL_IDLE_PRIORITY_LOWEST;
@@ -396,6 +387,7 @@ Timer& Timer::operator=( const Timer& rTimer )
mbActive = false;
mnTimeout = rTimer.mnTimeout;
mnPriority = rTimer.mnPriority;
+ mnDefaultPriority = rTimer.mnDefaultPriority;
maTimeoutHdl = rTimer.maTimeoutHdl;
if ( rTimer.IsActive() )
More information about the Libreoffice-commits
mailing list