[Libreoffice-commits] core.git: Branch 'feature/priorities' - 2 commits - include/vcl vcl/source
Tobias Madl
tobias.madl.dev at gmail.com
Thu Mar 5 06:06:33 PST 2015
include/vcl/scheduler.hxx | 3 ++-
include/vcl/timer.hxx | 4 +++-
vcl/source/app/scheduler.cxx | 41 +++++++++++++++++++++++++++++++++++++----
vcl/source/app/svapp.cxx | 3 ++-
vcl/source/app/timer.cxx | 33 ++++++++++++++++++++++++++++++---
5 files changed, 74 insertions(+), 10 deletions(-)
New commits:
commit ce0998127e9e0af03f1d66f5dd6aab4252f7caf1
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date: Thu Mar 5 14:05:15 2015 +0000
Timer: added new saltimer handling
Change-Id: Icdc5abf9dca727a8cc312ddb5861f7a34a38bbe1
diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index af17016..30f2e1a 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -60,6 +60,7 @@ protected:
friend struct ImplSchedulerData;
virtual void SetDeletionFlags();
virtual bool ReadyForSchedule( bool bTimer ) { return !bTimer; }
+ virtual sal_uLong UpdateMinPeriod( sal_uLong nMinPeriod, sal_uLong nTime );
public:
Scheduler();
@@ -79,7 +80,7 @@ public:
bool IsActive() const { return mbActive; }
- Scheduler& operator=( const Scheduler& Scheduler );
+ Scheduler& operator=( const Scheduler& rScheduler );
static void ImplDeInitScheduler();
/// Process all pending idle tasks ahead of time in priority order.
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index d2db1d4..a999559 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -32,6 +32,7 @@ protected:
void SetDeletionFlags() SAL_OVERRIDE;
bool ReadyForSchedule( bool bTimer ) SAL_OVERRIDE;
+ sal_uLong UpdateMinPeriod( sal_uLong nMinPeriod, sal_uLong nTime ) SAL_OVERRIDE;
public:
Timer();
@@ -44,9 +45,10 @@ public:
void SetTimeoutHdl( const Link& rLink ) { maTimeoutHdl = rLink; }
const Link& GetTimeoutHdl() const { return maTimeoutHdl; }
virtual void Invoke() SAL_OVERRIDE;
- void Timeout() { Invoke(); }
+ void Timeout() { Invoke(); }
Timer& operator=( const Timer& rTimer );
void Start() SAL_OVERRIDE;
+ static void ImplStartTimer( ImplSVData* pSVData, sal_uLong nMS );
};
/// An auto-timer is a multi-shot timer re-emitting itself at
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 06de1ba..ef5e1f0 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -20,6 +20,8 @@
#include <svdata.hxx>
#include <tools/time.hxx>
#include <vcl/scheduler.hxx>
+#include <vcl/timer.hxx>
+#include <saltimer.hxx>
void ImplSchedulerData::Invoke()
{
@@ -70,6 +72,10 @@ void Scheduler::ImplDeInitScheduler()
{
ImplSVData* pSVData = ImplGetSVData();
ImplSchedulerData* pSchedulerData = pSVData->mpFirstSchedulerData;
+ if (pSVData->mpSalTimer)
+ {
+ pSVData->mpSalTimer->Stop();
+ }
if ( pSchedulerData )
{
@@ -87,7 +93,11 @@ void Scheduler::ImplDeInitScheduler()
while ( pSchedulerData );
pSVData->mpFirstSchedulerData = NULL;
+ pSVData->mnTimerPeriod = 0;
}
+
+ delete pSVData->mpSalTimer;
+ pSVData->mpSalTimer = 0;
}
void Scheduler::CallbackTaskScheduling(bool ignore)
@@ -102,19 +112,26 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
ImplSchedulerData* pSchedulerData = NULL;
ImplSchedulerData* pPrevSchedulerData = NULL;
ImplSVData* pSVData = ImplGetSVData();
+ sal_uLong nTime = tools::Time::GetSystemTicks();
+ sal_uLong nMinPeriod = ((sal_uLong)0xFFFFFFFF);
pSVData->mnTimerUpdate++;
if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimer)))
{
- pSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
+ pSchedulerData->mnUpdateTime = nTime;
pSchedulerData->Invoke();
}
pSchedulerData = pSVData->mpFirstSchedulerData;
while ( pSchedulerData )
{
+ if( pSchedulerData->mbInScheduler )
+ {
+ pPrevSchedulerData = pSchedulerData;
+ pSchedulerData = pSchedulerData->mpNext;
+ }
// Should Task be released from scheduling?
- if ( pSchedulerData->mbDelete )
+ else if ( pSchedulerData->mbDelete )
{
if ( pPrevSchedulerData )
pPrevSchedulerData->mpNext = pSchedulerData->mpNext;
@@ -128,15 +145,31 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
}
else
{
- if( !pSchedulerData->mbInScheduler )
- pSchedulerData->mnUpdateStack = 0;
+ pSchedulerData->mnUpdateStack = 0;
+ nMinPeriod = pSchedulerData->mpScheduler->UpdateMinPeriod( nMinPeriod, nTime );
pPrevSchedulerData = pSchedulerData;
pSchedulerData = pSchedulerData->mpNext;
}
}
+
+ // delete clock if no more timers available
+ if ( !pSVData->mpFirstSchedulerData )
+ {
+ if ( pSVData->mpSalTimer )
+ pSVData->mpSalTimer->Stop();
+ pSVData->mnTimerPeriod = ((sal_uLong)0xFFFFFFFF);
+ }
+ else
+ Timer::ImplStartTimer( pSVData, nMinPeriod );
pSVData->mnTimerUpdate--;
}
+sal_uLong Scheduler::UpdateMinPeriod( sal_uLong nMinPeriod, sal_uLong nTime )
+{
+ (void)nTime;
+ return nMinPeriod;
+}
+
void Scheduler::SetPriority( SchedulerPriority ePriority )
{
meDefaultPriority = ePriority;
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index b8be2d7..4dec9af 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -26,7 +26,7 @@
#define MAX_TIMER_PERIOD ((sal_uLong)0xFFFFFFFF)
-static void ImplStartTimer( ImplSVData* pSVData, sal_uLong nMS )
+void Timer::ImplStartTimer( ImplSVData* pSVData, sal_uLong nMS )
{
if ( !nMS )
nMS = 1;
@@ -55,6 +55,33 @@ bool Timer::ReadyForSchedule( bool bTimer )
return (mpSchedulerData->mnUpdateTime + mnTimeout) <= tools::Time::GetSystemTicks();
}
+sal_uLong Timer::UpdateMinPeriod( sal_uLong nMinPeriod, sal_uLong nTime )
+{
+ sal_uLong nNewTime = tools::Time::GetSystemTicks();
+ sal_uLong nDeltaTime;
+ //determine smallest time slot
+ if( mpSchedulerData->mnUpdateTime == nTime )
+ {
+ nDeltaTime = mnTimeout;
+ if( nDeltaTime < nMinPeriod )
+ nMinPeriod = nDeltaTime;
+ }
+ else
+ {
+ nDeltaTime = mpSchedulerData->mnUpdateTime + mnTimeout;
+ if( nDeltaTime < nNewTime )
+ nMinPeriod = 1;
+ else
+ {
+ nDeltaTime -= nNewTime;
+ if( nDeltaTime < nMinPeriod )
+ nMinPeriod = nDeltaTime;
+ }
+ }
+
+ return nMinPeriod;
+}
+
Timer::Timer() : Scheduler()
{
mnTimeout = 1;
@@ -86,7 +113,7 @@ void Timer::Start()
pSVData->mpSalTimer->SetCallback( CallbackTaskScheduling );
}
if ( mnTimeout < pSVData->mnTimerPeriod )
- ImplStartTimer( pSVData, mnTimeout );
+ Timer::ImplStartTimer( pSVData, mnTimeout );
}
void Timer::SetTimeout( sal_uLong nNewTimeout )
@@ -97,7 +124,7 @@ void Timer::SetTimeout( sal_uLong nNewTimeout )
{
ImplSVData* pSVData = ImplGetSVData();
if ( !pSVData->mnTimerUpdate && (mnTimeout < pSVData->mnTimerPeriod) )
- ImplStartTimer( pSVData, mnTimeout );
+ Timer::ImplStartTimer( pSVData, mnTimeout );
}
}
commit d8d910e0771f76a010abf3d7d8e722830aa8adc8
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date: Thu Mar 5 11:57:50 2015 +0000
Clean up minor fixes
Change-Id: Icdf85d6f6f5734a3cf952def8782efe9edc7c0a9
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 33fbf0a..0064ec0 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -346,7 +346,7 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
//while ( pSVData->mbNotAllTimerCalled )
// Timer::ImplTimerCallbackProc();
- //Process all idles
+ //Process all Tasks
Scheduler::ProcessTaskScheduling(false);
pSVData->maAppData.mnDispatchLevel++;
@@ -367,6 +367,7 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
// e.g. on OS X; need to trigger timer checks manually
if( pSVData->maAppData.mbNoYield )
{
+ //Process all timers
Scheduler::ProcessTaskScheduling(true);
}
More information about the Libreoffice-commits
mailing list