include/vcl/idle.hxx | 23 +++++++++++++---------- vcl/source/app/idle.cxx | 29 +++++++++++++++++------------ 2 files changed, 30 insertions(+), 22 deletions(-)
New commits: commit bc637c2096621061d1a5dc37aaebc657f195ac7f Author: Jennifer Liebel <jliebe...@gmail.com> Date: Tue Jan 20 12:42:43 2015 +0000 insert comments and corrected priority values Change-Id: I2c73bb2b2edd3b830dad5d1f7d8f7bc72622b11c diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx index 5a46462..0415575 100644 --- a/include/vcl/idle.hxx +++ b/include/vcl/idle.hxx @@ -27,18 +27,20 @@ struct ImplIdleData; struct ImplSVData; -// The timemarks behind the priorities is the catgorizing of timer to idle +// The timemarks behind the priorities are need to change timer to idle. It is to convert +// timeout values to priorities. enum class IdlePriority { - VCL_IDLE_PRIORITY_STARVATIONPROTECTION = -1, // Do not use this for normal prioritizing - VCL_IDLE_PRIORITY_HIGHEST = 0, // -> 0ms - VCL_IDLE_PRIORITY_HIGH = 1, // -> 1ms - VCL_IDLE_PRIORITY_DEFAULT = 1, // -> 1ms - VCL_IDLE_PRIORITY_REPAINT = 2, // -> 30ms + VCL_IDLE_PRIORITY_STARVATIONPROTECTION = -1, // Do not use this for normal prioritizing! + + VCL_IDLE_PRIORITY_HIGHEST = 0, // -> 0ms + VCL_IDLE_PRIORITY_HIGH = 1, // -> 1ms + VCL_IDLE_PRIORITY_DEFAULT = 1, // -> 1ms + VCL_IDLE_PRIORITY_REPAINT = 2, // -> 30ms VCL_IDLE_PRIORITY_RESIZE = 3, // -> 50ms VCL_IDLE_PRIORITY_MEDIUM = 3, // -> 50ms - VCL_IDLE_PRIORITY_LOW = 5, // -> 100ms - VCL_IDLE_PRIORITY_LOWER = 6, // -> 200ms - VCL_IDLE_PRIORITY_LOWEST = 7 // -> 400ms + VCL_IDLE_PRIORITY_LOW = 4, // -> 100ms + VCL_IDLE_PRIORITY_LOWER = 5, // -> 200ms + VCL_IDLE_PRIORITY_LOWEST = 6 // -> 400ms }; @@ -65,8 +67,9 @@ public: /// Make it possible to associate a callback with this idle handler /// of course, you can also sub-class and override 'DoIdle' void SetIdleHdl( const Link& rLink ) { maIdleHdl = rLink; } - const Link& GetIdleHdl() const { return maIdleHdl; } + const Link& GetIdleHdl() const { return maIdleHdl; } + // Call idle handler virtual void DoIdle(); void Start(); diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index 6ad03d2..37299de 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -26,9 +26,9 @@ struct ImplIdleData { - ImplIdleData* mpNext; // Pointer to the next Instance - Idle* mpIdle; // Pointer to VCL Idle instance - bool mbDelete; // Was Idle deleted during Update()? + ImplIdleData* mpNext; // Pointer to the next Instance + Idle* mpIdle; // Pointer to VCL Idle instance + bool mbDelete; // Was Idle deleted during Update()? bool mbInIdle; // Are we in a idle handler? void Invoke() @@ -60,6 +60,9 @@ struct ImplIdleData 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->mpIdle->GetPriority() < pMostUrgent->mpIdle->GetPriority() ) { IncreasePriority(pMostUrgent->mpIdle); @@ -77,7 +80,8 @@ struct ImplIdleData { switch(pIdle->GetPriority()) { - // Increase priority based on their current priority + // Increase priority based on their current priority; + // (so don't use VCL_IDLE_PRIORITY_STARVATIONPROTECTION for default-priority!) case IdlePriority::VCL_IDLE_PRIORITY_STARVATIONPROTECTION: break; // If already highest priority -> extra state for starving tasks @@ -132,10 +136,11 @@ void Idle::ImplDeInitIdle() void Idle::ProcessAllIdleHandlers() { - // process all pending Idle + // process all pending idle ImplIdleData* pIdleData = NULL; ImplIdleData* pPrevIdleData = NULL; ImplSVData* pSVData = ImplGetSVData(); + // timer can interrupt idle while (!Timer::TimerReady() && (pIdleData = ImplIdleData::GetFirstIdle())) { pIdleData->Invoke(); @@ -144,7 +149,7 @@ void Idle::ProcessAllIdleHandlers() pIdleData = pSVData->mpFirstIdleData; while ( pIdleData ) { - // Was Idle destroyed in the meantime? + // Was idle destroyed in the meantime? if ( pIdleData->mbDelete ) { if ( pPrevIdleData ) @@ -188,8 +193,8 @@ void Idle::Start() if ( !mpIdleData ) { // insert Idle - mpIdleData = new ImplIdleData; - mpIdleData->mpIdle = this; + mpIdleData = new ImplIdleData; + mpIdleData->mpIdle = this; mpIdleData->mbInIdle = false; // insert last due to SFX! @@ -222,10 +227,10 @@ Idle& Idle::operator=( const Idle& rIdle ) if ( IsActive() ) Stop(); - mbActive = false; - mePriority = rIdle.mePriority; + mbActive = false; + mePriority = rIdle.mePriority; meDefaultPriority = rIdle.meDefaultPriority; - maIdleHdl = rIdle.maIdleHdl; + maIdleHdl = rIdle.maIdleHdl; if ( rIdle.IsActive() ) Start(); @@ -260,4 +265,4 @@ Idle::~Idle() mpIdleData->mpIdle = NULL; } } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits