[Libreoffice-commits] core.git: Branch 'feature/priorities' - 2 commits - editeng/source sc/inc sc/source sd/source svtools/source sw/source vcl/source

Tobias Madl tobias.madl.dev at gmail.com
Fri Dec 19 05:06:14 PST 2014


 editeng/source/editeng/impedit.hxx                            |    6 -
 editeng/source/editeng/impedit2.cxx                           |    6 -
 editeng/source/editeng/impedit3.cxx                           |    2 
 editeng/source/editeng/impedit4.cxx                           |    4 
 sc/inc/scmod.hxx                                              |    2 
 sc/source/ui/app/scmod.cxx                                    |   47 ++++++++--
 sd/source/ui/framework/configuration/ConfigurationUpdater.cxx |   20 ++--
 sd/source/ui/framework/configuration/ConfigurationUpdater.hxx |    2 
 sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx          |   18 +--
 sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx          |    2 
 svtools/source/graphic/grfcache.cxx                           |    6 -
 svtools/source/graphic/grfcache.hxx                           |    2 
 sw/source/core/doc/DocumentTimerManager.cxx                   |   18 +--
 sw/source/core/inc/DocumentTimerManager.hxx                   |    2 
 vcl/source/app/svapp.cxx                                      |    3 
 vcl/source/app/timer.cxx                                      |    2 
 16 files changed, 90 insertions(+), 52 deletions(-)

New commits:
commit a3b404e21e7ffd74b1456f3e150f6ca361480c1d
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date:   Fri Dec 19 13:02:50 2014 +0000

    Timer: first independend idle use
    
    Change-Id: I27985e456447ef3d71cae39c2acaf59b3aa60b83

diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 7c4a76d..17c589e 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -355,8 +355,11 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents )
 
     // run timers that have timed out
     if ( !pSVData->mbNoCallTimer )
+    {
         while ( pSVData->mbNotAllTimerCalled )
             Timer::ImplTimerCallbackProc();
+        Timer::Timer::ProcessAllIdleHandlers();
+    }
 
     pSVData->maAppData.mnDispatchLevel++;
     // do not wait for events if application was already quit; in that
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 529c8b5..0dea56d 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -151,7 +151,7 @@ void Timer::ImplTimerCallbackProc()
         // 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 )
+             !pTimerData->mbDelete && !pTimerData->mbInTimeout && !pTimerData->mpTimer->mbIdle)
         {
             // time has expired
             if ( pTimerData->GetDeadline() <= nTime )
commit 256d5241f1a242f2e20608a0ded2554bfece9ac5
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date:   Fri Dec 19 13:01:46 2014 +0000

    Timer: Reversed some Idles to Timer
    
    Change-Id: I213722cc98490430378014290cb09cca9e469bbb

diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index f98f943..c6e41d4 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -465,7 +465,7 @@ private:
 
     IdleFormattter      aIdleFormatter;
 
-    Idle                aOnlineSpellIdle;
+    Timer               aOnlineSpellTimer;
 
     // If it is detected at one point that the StatusHdl has to be called, but
     // this should not happen immediately (critical section):
@@ -979,8 +979,8 @@ public:
 
     inline EditEngine*  GetEditEnginePtr() const    { return pEditEngine; }
 
-    void                StartOnlineSpellTimer()     { aOnlineSpellIdle.Start(); }
-    void                StopOnlineSpellTimer()      { aOnlineSpellIdle.Stop(); }
+    void                StartOnlineSpellTimer()     { aOnlineSpellTimer.Start(); }
+    void                StopOnlineSpellTimer()      { aOnlineSpellTimer.Stop(); }
 
     const OUString&     GetAutoCompleteText() const { return aAutoCompleteText; }
     void                SetAutoCompleteText(const OUString& rStr, bool bUpdateTipWindow);
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index f4b48b8..fcc9c24 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -148,8 +148,8 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
     aIdleFormatter.SetPriority( VCL_IDLE_PRIORITY_REPAINT );
     aIdleFormatter.SetIdleHdl( LINK( this, ImpEditEngine, IdleFormatHdl ) );
 
-    aOnlineSpellIdle.SetPriority( VCL_IDLE_PRIORITY_LOW );
-    aOnlineSpellIdle.SetIdleHdl( LINK( this, ImpEditEngine, OnlineSpellHdl ) );
+    aOnlineSpellTimer.SetTimeout( 100 );
+    aOnlineSpellTimer.SetTimeoutHdl( LINK( this, ImpEditEngine, OnlineSpellHdl ) );
 
     // Access data already from here on!
     SetRefDevice( NULL );
@@ -163,7 +163,7 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
 ImpEditEngine::~ImpEditEngine()
 {
     aStatusTimer.Stop();
-    aOnlineSpellIdle.Stop();
+    aOnlineSpellTimer.Stop();
     aIdleFormatter.Stop();
 
     // Destroying templates may otherwise cause unnecessary formatting,
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 39db002..e4af131 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -312,7 +312,7 @@ IMPL_LINK_NOARG(ImpEditEngine, OnlineSpellHdl)
     if ( !Application::AnyInput( VCL_INPUT_KEYBOARD ) && GetUpdateMode() && IsFormatted() )
         DoOnlineSpelling();
     else
-        aOnlineSpellIdle.Start();
+        aOnlineSpellTimer.Start();
 
     return 0;
 }
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index dd5c2f0..5d17194 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1478,7 +1478,7 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, bool bMultipleDoc )
     if ( !xSpeller.is() )
         return EE_SPELL_NOSPELLER;
 
-    aOnlineSpellIdle.Stop();
+    aOnlineSpellTimer.Stop();
 
     // In MultipleDoc always from the front / rear ...
     if ( bMultipleDoc )
@@ -2447,7 +2447,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
             break;
     }
     if ( bRestartTimer )
-        aOnlineSpellIdle.Start();
+        aOnlineSpellTimer.Start();
 }
 
 
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 7d23cc7..2c513a9 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -81,7 +81,7 @@ class ScAnyRefModalDlg;
 
 class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
 {
-    Idle                aIdle;
+    Timer               aIdleTimer;
     Idle                aSpellIdle;
     ScDragData*         mpDragData;
     ScClipData*         mpClipData;
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index bfb85ca..0f3f80f 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -112,6 +112,13 @@
 #include "formulagroup.hxx"
 #include <documentlinkmgr.hxx>
 
+#define SC_IDLE_MIN     150
+#define SC_IDLE_MAX     3000
+#define SC_IDLE_STEP    75
+#define SC_IDLE_COUNT   50
+
+static sal_uInt16 nIdleCount = 0;
+
 SFX_IMPL_INTERFACE(ScModule, SfxShell)
 
 void ScModule::InitInterface_Impl()
@@ -169,9 +176,9 @@ ScModule::ScModule( SfxObjectFactory* pFact ) :
 
     aSpellIdle.SetPriority(VCL_IDLE_PRIORITY_REPAINT);
     aSpellIdle.SetIdleHdl( LINK( this, ScModule, SpellTimerHdl ) );
-    aIdle.SetPriority(VCL_IDLE_PRIORITY_LOWER);
-    aIdle.SetIdleHdl( LINK( this, ScModule, IdleHandler ) );
-    aIdle.Start();
+    aIdleTimer.SetTimeout(SC_IDLE_MIN);
+    aIdleTimer.SetTimeoutHdl( LINK( this, ScModule, IdleHandler ) );
+    aIdleTimer.Start();
 
     pMessagePool = new ScMessagePool;
     pMessagePool->FreezeIdRanges();
@@ -1844,7 +1851,11 @@ void ScModule::EndReference()
  */
 void ScModule::AnythingChanged()
 {
-    aIdle.SetPriority(VCL_IDLE_PRIORITY_LOWER);
+    sal_uLong nOldTime = aIdleTimer.GetTimeout();
+    if ( nOldTime != SC_IDLE_MIN )
+        aIdleTimer.SetTimeout( SC_IDLE_MIN );
+
+    nIdleCount = 0;
 }
 
 static void lcl_CheckNeedsRepaint( ScDocShell* pDocShell )
@@ -1864,7 +1875,7 @@ IMPL_LINK_NOARG(ScModule, IdleHandler)
 {
     if ( Application::AnyInput( VCL_INPUT_MOUSEANDKEYBOARD ) )
     {
-        aIdle.Start(); // Timeout unchanged
+        aIdleTimer.Start(); // Timeout unchanged
         return 0;
     }
 
@@ -1905,12 +1916,30 @@ IMPL_LINK_NOARG(ScModule, IdleHandler)
         }
     }
 
-    if (bMore)
-        aIdle.SetPriority(VCL_IDLE_PRIORITY_LOW);
+    sal_uLong nOldTime = aIdleTimer.GetTimeout();
+    sal_uLong nNewTime = nOldTime;
+    if ( bMore )
+    {
+        nNewTime = SC_IDLE_MIN;
+        nIdleCount = 0;
+    }
     else
-        aIdle.SetPriority(VCL_IDLE_PRIORITY_LOWEST);
+    {
+        // Set SC_IDLE_COUNT to initial Timeout - increase afterwards
+        if ( nIdleCount < SC_IDLE_COUNT )
+            ++nIdleCount;
+        else
+        {
+            nNewTime += SC_IDLE_STEP;
+            if ( nNewTime > SC_IDLE_MAX )
+                nNewTime = SC_IDLE_MAX;
+        }
+    }
+    if ( nNewTime != nOldTime )
+        aIdleTimer.SetTimeout( nNewTime );
+
 
-    aIdle.Start();
+    aIdleTimer.Start();
     return 0;
 }
 
diff --git a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx
index 42b2eb7..10ea920 100644
--- a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx
+++ b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx
@@ -36,7 +36,11 @@ using ::sd::framework::FrameworkHelper;
 using ::std::vector;
 
 namespace {
+static const sal_Int32 snShortTimeout (100);
+static const sal_Int32 snNormalTimeout (1000);
+static const sal_Int32 snLongTimeout (10000);
 static const sal_Int32 snShortTimeoutCountThreshold (1);
+static const sal_Int32 snNormalTimeoutCountThreshold (5);
 }
 
 namespace sd { namespace framework {
@@ -66,21 +70,21 @@ ConfigurationUpdater::ConfigurationUpdater (
       mbUpdatePending(false),
       mbUpdateBeingProcessed(false),
       mnLockCount(0),
-      maUpdateIdle(),
+      maUpdateTimer(),
       mnFailedUpdateCount(0),
       mpResourceManager(rpResourceManager)
 {
     // Prepare the timer that is started when after an update the current
     // and the requested configuration differ.  With the timer we try
     // updates until the two configurations are the same.
-    maUpdateIdle.SetPriority(VCL_IDLE_PRIORITY_LOWEST);
-    maUpdateIdle.SetIdleHdl(LINK(this,ConfigurationUpdater,TimeoutHandler));
+    maUpdateTimer.SetTimeout(snNormalTimeout);
+    maUpdateTimer.SetTimeoutHdl(LINK(this,ConfigurationUpdater,TimeoutHandler));
     SetControllerManager(rxControllerManager);
 }
 
 ConfigurationUpdater::~ConfigurationUpdater (void)
 {
-    maUpdateIdle.Stop();
+    maUpdateTimer.Stop();
 }
 
 void ConfigurationUpdater::SetControllerManager(
@@ -214,11 +218,13 @@ void ConfigurationUpdater::CheckUpdateSuccess (void)
     if ( ! AreConfigurationsEquivalent(mxCurrentConfiguration, mxRequestedConfiguration))
     {
         if (mnFailedUpdateCount <= snShortTimeoutCountThreshold)
-            maUpdateIdle.SetPriority(VCL_IDLE_PRIORITY_LOW);
+            maUpdateTimer.SetTimeout(snShortTimeout);
+        else if (mnFailedUpdateCount < snNormalTimeoutCountThreshold)
+            maUpdateTimer.SetTimeout(snNormalTimeout);
         else
-            maUpdateIdle.SetPriority(VCL_IDLE_PRIORITY_LOWEST);
+            maUpdateTimer.SetTimeout(snLongTimeout);
         ++mnFailedUpdateCount;
-        maUpdateIdle.Start();
+        maUpdateTimer.Start();
     }
     else
     {
diff --git a/sd/source/ui/framework/configuration/ConfigurationUpdater.hxx b/sd/source/ui/framework/configuration/ConfigurationUpdater.hxx
index 382fac6..bde705f 100644
--- a/sd/source/ui/framework/configuration/ConfigurationUpdater.hxx
+++ b/sd/source/ui/framework/configuration/ConfigurationUpdater.hxx
@@ -131,7 +131,7 @@ private:
         This is used to overcome problems with resources that become
         available asynchronously.
     */
-    Idle maUpdateIdle;
+    Timer  maUpdateTimer;
 
     /** The number of failed updates (those after which the current
         configuration is not equivalent to the requested configuration) is
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
index 1364bee..dcbdff7 100644
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
@@ -32,7 +32,7 @@ QueueProcessor::QueueProcessor (
     const bool bDoSuperSampling,
     const SharedCacheContext& rpCacheContext)
     : maMutex(),
-      maIdle(),
+      maTimer(),
       mnTimeBetweenHighPriorityRequests (10/*ms*/),
       mnTimeBetweenLowPriorityRequests (100/*ms*/),
       mnTimeBetweenRequestsWhenNotIdle (1000/*ms*/),
@@ -58,8 +58,8 @@ QueueProcessor::QueueProcessor (
     if (aTimeBetweenReqeusts.has<sal_Int32>())
         aTimeBetweenReqeusts >>= mnTimeBetweenRequestsWhenNotIdle;
 
-    maIdle.SetIdleHdl (LINK(this,QueueProcessor,ProcessRequestHdl));
-    maIdle.SetPriority (VCL_IDLE_PRIORITY_REPAINT);
+    maTimer.SetTimeoutHdl (LINK(this,QueueProcessor,ProcessRequestHdl));
+    maTimer.SetTimeout (10);
 }
 
 QueueProcessor::~QueueProcessor (void)
@@ -70,20 +70,20 @@ void QueueProcessor::Start (int nPriorityClass)
 {
     if (mbIsPaused)
         return;
-    if ( ! maIdle.IsActive())
+    if ( ! maTimer.IsActive())
     {
         if (nPriorityClass == 0)
-            maIdle.SetPriority (VCL_IDLE_PRIORITY_REPAINT);
+            maTimer.SetTimeout (10);
         else
-            maIdle.SetPriority (VCL_IDLE_PRIORITY_LOW);
-        maIdle.Start();
+            maTimer.SetTimeout (100);
+        maTimer.Start();
     }
 }
 
 void QueueProcessor::Stop (void)
 {
-    if (maIdle.IsActive())
-        maIdle.Stop();
+    if (maTimer.IsActive())
+        maTimer.Stop();
 }
 
 void QueueProcessor::Pause (void)
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
index 6993d5c..df65ffa 100644
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
@@ -92,7 +92,7 @@ private:
     */
     ::osl::Mutex maMutex;
 
-    Idle  maIdle;
+    Timer  maTimer;
     DECL_LINK(ProcessRequestHdl, void *);
     sal_uInt32 mnTimeBetweenHighPriorityRequests;
     sal_uInt32 mnTimeBetweenLowPriorityRequests;
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index f5baadb..4d28574 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -824,9 +824,9 @@ GraphicCache::GraphicCache( sal_uLong nDisplayCacheSize, sal_uLong nMaxObjDispla
     mnMaxObjDisplaySize     ( nMaxObjDisplayCacheSize ),
     mnUsedDisplaySize       ( 0UL )
 {
-    maReleaseIdle.SetIdleHdl( LINK( this, GraphicCache, ReleaseTimeoutHdl ) );
-    maReleaseIdle.SetPriority( VCL_IDLE_PRIORITY_LOWEST );
-    maReleaseIdle.Start();
+    maReleaseTimer.SetTimeoutHdl( LINK( this, GraphicCache, ReleaseTimeoutHdl ) );
+    maReleaseTimer.SetTimeout( 10000 );
+    maReleaseTimer.Start();
 }
 
 GraphicCache::~GraphicCache()
diff --git a/svtools/source/graphic/grfcache.hxx b/svtools/source/graphic/grfcache.hxx
index e8259e7..ddb6f6b 100644
--- a/svtools/source/graphic/grfcache.hxx
+++ b/svtools/source/graphic/grfcache.hxx
@@ -39,7 +39,7 @@ private:
     typedef std::list< GraphicCacheEntry* > GraphicCacheEntryList;
     typedef std::list< GraphicDisplayCacheEntry* > GraphicDisplayCacheEntryList;
 
-    Idle                    maReleaseIdle;
+    Timer                   maReleaseTimer;
     GraphicCacheEntryList   maGraphicCache;
     GraphicDisplayCacheEntryList maDisplayCache;
     sal_uLong               mnReleaseTimeoutSeconds;
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
index 5c97d2c..d65c24a 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -42,42 +42,42 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc
                                                                 mbStartIdleTimer( false ),
                                                                 mIdleBlockCount( 0 )
 {
-    maIdle.SetPriority( VCL_IDLE_PRIORITY_LOWEST );
-    maIdle.SetIdleHdl( LINK( this, DocumentTimerManager, DoIdleJobs) );
+    maIdleTimer.SetTimeout( 600 );
+    maIdleTimer.SetTimeoutHdl( LINK( this, DocumentTimerManager, DoIdleJobs) );
 }
 
 void DocumentTimerManager::StartIdling()
 {
     mbStartIdleTimer = true;
     if( !mIdleBlockCount )
-        maIdle.Start();
+        maIdleTimer.Start();
 }
 
 void DocumentTimerManager::StopIdling()
 {
     mbStartIdleTimer = false;
-    maIdle.Stop();
+    maIdleTimer.Stop();
 }
 
 void DocumentTimerManager::BlockIdling()
 {
-    maIdle.Stop();
+    maIdleTimer.Stop();
     ++mIdleBlockCount;
 }
 
 void DocumentTimerManager::UnblockIdling()
 {
     --mIdleBlockCount;
-    if( !mIdleBlockCount && mbStartIdleTimer && !maIdle.IsActive() )
-        maIdle.Start();
+    if( !mIdleBlockCount && mbStartIdleTimer && !maIdleTimer.IsActive() )
+        maIdleTimer.Start();
 }
 
 void DocumentTimerManager::StartBackgroundJobs() {
     // Trigger DoIdleJobs(), asynchronously.
-    maIdle.Start();
+    maIdleTimer.Start();
 }
 
-IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer )
+IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pTimer )
 {
 #ifdef TIMELOG
     static ::rtl::Logfile* pModLogFile = 0;
diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx
index 878c39b..42351cc 100644
--- a/sw/source/core/inc/DocumentTimerManager.hxx
+++ b/sw/source/core/inc/DocumentTimerManager.hxx
@@ -60,7 +60,7 @@ private:
 
      bool mbStartIdleTimer; //< idle timer mode start/stop
      sal_Int32 mIdleBlockCount;
-     Idle maIdle;
+     Timer  maIdleTimer;
 };
 
 }


More information about the Libreoffice-commits mailing list