Kaydet (Commit) 3f64e7c1 authored tarafından Tobias Madl's avatar Tobias Madl

Optimized Timer/Idle code

Change-Id: I285bd632faba5a29a770404d6967f4faf7667b16
üst 4c3cea26
......@@ -64,6 +64,7 @@ public:
static void ImplDeInitTimer();
static void ImplTimerCallbackProc();
static bool TimerReady();
static bool CheckExpiredTimer(const bool bDoInvoke);
};
/// An auto-timer is a multi-shot timer re-emitting itself at
......
......@@ -320,7 +320,6 @@ struct ImplSVData
sal_uLong mnTimerPeriod; // current timer period
sal_uLong mnTimerUpdate; // TimerCallbackProcs on stack
bool mbNotAllTimerCalled; // true: Timer must still be processed
bool mbNoCallTimer; // true: No Timeout calls
ImplSVAppData maAppData; // indepen data for class Application
ImplSVGDIData maGDIData; // indepen data for Output classes
ImplSVWinData maWinData; // indepen data for Windows classes
......
......@@ -185,7 +185,6 @@ void Idle::Start()
// insert timer and start
mpIdleData = new ImplIdleData;
mpIdleData->mpIdle = this;
mpIdleData->mbDelete = false;
mpIdleData->mbInIdle = false;
// insert last due to SFX!
......@@ -202,14 +201,7 @@ void Idle::Start()
else
pSVData->mpFirstIdleData = mpIdleData;
}
else if( !mpIdleData->mpIdle ) // TODO: remove when guilty found
{
OSL_FAIL( "Idle::Start() on a destroyed Idle!" );
}
else
{
mpIdleData->mbDelete = false;
}
mpIdleData->mbDelete = false;
}
void Idle::Stop()
......
......@@ -343,11 +343,8 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
ImplSVData* pSVData = ImplGetSVData();
// run timers that have timed out
if ( !pSVData->mbNoCallTimer )
{
while ( pSVData->mbNotAllTimerCalled )
Timer::ImplTimerCallbackProc();
}
while ( pSVData->mbNotAllTimerCalled )
Timer::ImplTimerCallbackProc();
//Process all idles
Idle::Idle::ProcessAllIdleHandlers();
......@@ -368,7 +365,7 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
// the system timer events will not necessarily come in non waiting mode
// e.g. on OS X; need to trigger timer checks manually
if( pSVData->maAppData.mbNoYield && !pSVData->mbNoCallTimer )
if( pSVData->maAppData.mbNoYield )
{
do
{
......
......@@ -117,33 +117,10 @@ void Timer::ImplTimerCallbackProc( bool idle )
sal_uLong nDeltaTime;
sal_uLong nTime = tools::Time::GetSystemTicks();
if ( pSVData->mbNoCallTimer )
return;
pSVData->mnTimerUpdate++;
pSVData->mbNotAllTimerCalled = true;
// find timer where the timer handler needs to be called
pTimerData = pSVData->mpFirstTimerData;
while ( pTimerData )
{
// If the timer is not new, was not deleted, and if it is not in the timeout handler, then
// call the handler as soon as the time is up.
if ( (pTimerData->mnTimerUpdate < pSVData->mnTimerUpdate) &&
!pTimerData->mbDelete && !pTimerData->mbInTimeout)
{
// time has expired
if ( pTimerData->GetDeadline() <= nTime )
{
// set new update time
pTimerData->mnUpdateTime = nTime;
pTimerData->Invoke();
}
}
pTimerData = pTimerData->mpNext;
}
Timer::CheckExpiredTimer(true);
// determine new time
sal_uLong nNewTime = tools::Time::GetSystemTicks();
......@@ -211,11 +188,17 @@ void Timer::ImplTimerCallbackProc( bool idle )
}
bool Timer::TimerReady()
{
return Timer::CheckExpiredTimer(false);
}
bool Timer::CheckExpiredTimer(bool bDoInvoke)
{
// find timer where the timer handler needs to be called
ImplSVData* pSVData = ImplGetSVData();
ImplTimerData* pTimerData = pSVData->mpFirstTimerData;
sal_uLong nTime = tools::Time::GetSystemTicks();
bool timerExpired = false;
while ( pTimerData )
{
// If the timer is not new, was not deleted, and if it is not in the timeout handler, then
......@@ -226,13 +209,19 @@ bool Timer::TimerReady()
// time has expired
if ( pTimerData->GetDeadline() <= nTime )
{
return true;
if(bDoInvoke)
{
//Set new update Timer
pTimerData->mnUpdateTime = nTime;
pTimerData->Invoke();
}
timerExpired = true;
}
}
pTimerData = pTimerData->mpNext;
}
return false;
return timerExpired;
}
Timer::Timer():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment