Rebased ref, commits from common ancestor: commit 63a4a23496d43e78e24ad947e9d268cfa1d37eff Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Wed Sep 14 18:17:18 2016 +0200
Don't poll busy documents via idle task Creates a very busy idle-loop, for non-task work like mail merge. Change-Id: If7be82e4675008f23e6f4f6be5c40df40a231a8b diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx index 3c1369d..cb96054 100644 --- a/sw/source/core/doc/DocumentTimerManager.cxx +++ b/sw/source/core/doc/DocumentTimerManager.cxx @@ -40,47 +40,50 @@ namespace sw DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ), mbStartIdleTimer( false ), mIdleBlockCount( 0 ), - maIdle("DocumentTimerManagerIdleTimer") + maDocIdleTimer("DocumentTimerManagerIdleTimer") { - maIdle.SetPriority( SchedulerPriority::LOWEST ); - maIdle.SetIdleHdl( LINK( this, DocumentTimerManager, DoIdleJobs) ); - maIdle.SetDebugName( "sw::DocumentTimerManager maIdle" ); + maDocIdleTimer.SetPriority( SchedulerPriority::LOWEST ); + maDocIdleTimer.SetTimeoutHdl( LINK( this, DocumentTimerManager, DoIdleJobs) ); + maDocIdleTimer.SetDebugName( "sw::DocumentTimerManager maDocIdleTimer" ); } void DocumentTimerManager::StartIdling() { mbStartIdleTimer = true; if( !mIdleBlockCount ) - maIdle.Start(); + { + maDocIdleTimer.SetTimeout( 0 ); + maDocIdleTimer.Start(); + } } void DocumentTimerManager::StopIdling() { mbStartIdleTimer = false; - maIdle.Stop(); + maDocIdleTimer.Stop(); } void DocumentTimerManager::BlockIdling() { - maIdle.Stop(); + maDocIdleTimer.Stop(); ++mIdleBlockCount; } void DocumentTimerManager::UnblockIdling() { --mIdleBlockCount; - if( !mIdleBlockCount && mbStartIdleTimer && !maIdle.IsActive() ) - maIdle.Start(); + if( !mIdleBlockCount && mbStartIdleTimer && !maDocIdleTimer.IsActive() ) + maDocIdleTimer.Start(); } void DocumentTimerManager::StartBackgroundJobs() { // Trigger DoIdleJobs(), asynchronously. - if (!maIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0 - maIdle.Start(); + if (!maDocIdleTimer.IsActive()) //fdo#73165 if the timer is already running don't restart from 0 + maDocIdleTimer.Start(); } -IMPL_LINK_TYPED( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void ) +IMPL_LINK_TYPED( DocumentTimerManager, DoIdleJobs, Timer*, pTimer, void ) { #ifdef TIMELOG static ::rtl::Logfile* pModLogFile = 0; @@ -97,7 +100,8 @@ IMPL_LINK_TYPED( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void ) { if( rSh.ActionPend() ) { - pIdle->Start(); + pTimer->SetTimeout( 2000 ); + pTimer->Start(); return; } } @@ -121,7 +125,8 @@ IMPL_LINK_TYPED( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void ) (*pLayIter)->GetCurrShell()->LayoutIdle(); // Defer the remaining work. - pIdle->Start(); + pTimer->SetTimeout( 2000 ); + pTimer->Start(); return; } } @@ -137,7 +142,8 @@ IMPL_LINK_TYPED( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void ) if ( m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().IsInUpdateFields() || m_rDoc.getIDocumentFieldsAccess().IsExpFieldsLocked() ) { - pIdle->Start(); + pTimer->SetTimeout( 2000 ); + pTimer->Start(); return; } diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx index cf6b580..2644e45 100644 --- a/sw/source/core/inc/DocumentTimerManager.hxx +++ b/sw/source/core/inc/DocumentTimerManager.hxx @@ -48,7 +48,7 @@ public: void StartBackgroundJobs() override; // Our own 'IdleTimer' calls the following method - DECL_LINK_TYPED( DoIdleJobs, Idle *, void ); + DECL_LINK_TYPED( DoIdleJobs, Timer *, void ); virtual ~DocumentTimerManager() override; @@ -61,7 +61,7 @@ private: bool mbStartIdleTimer; //< idle timer mode start/stop sal_Int32 mIdleBlockCount; - Idle maIdle; + Timer maDocIdleTimer; }; } commit 953c162c55a2882dcb4146cd1f6a225b4ae03f96 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Wed Sep 14 15:33:54 2016 +0200 Really schedule Idle tasks immediatly There is really no reason to wait a millisecond for an idle. Change-Id: I7665d5f2e7d6ba3e01290a692bbc8e42c36b9986 diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx index 0f72b99..ea5a6b8 100644 --- a/include/vcl/scheduler.hxx +++ b/include/vcl/scheduler.hxx @@ -35,6 +35,11 @@ enum class SchedulerPriority { LOWEST ///< Low, very idle cleanup tasks }; +enum class IdleRunPolicy { + IDLE_VIA_TIMER, ///< Idles are scheduled via immediate timers (ImmediateTimeoutMs) + IDLE_VIA_LOOP ///< Return indicates processed events, so they are processed in a loop +}; + class VCL_DLLPUBLIC Scheduler { friend struct ImplSchedulerData; @@ -49,7 +54,7 @@ protected: SchedulerPriority mePriority; /// Scheduler priority // These should be constexpr static, when supported. - static const SAL_CONSTEXPR sal_uInt64 ImmediateTimeoutMs = 1; + static const SAL_CONSTEXPR sal_uInt64 ImmediateTimeoutMs = 0; static const SAL_CONSTEXPR sal_uInt64 InfiniteTimeoutMs = SAL_MAX_UINT64; static void ImplStartTimer(sal_uInt64 nMS); @@ -79,12 +84,13 @@ public: inline bool IsActive() const; Scheduler& operator=( const Scheduler& rScheduler ); - static void ImplDeInitScheduler(); + static void ImplDeInitScheduler(); /// Process one pending Timer with highhest priority static void CallbackTaskScheduling(); /// Process one pending task ahead of time with highest priority. - static bool ProcessTaskScheduling(); + static bool ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy + = IdleRunPolicy::IDLE_VIA_TIMER ); /// Process all events until we are idle static void ProcessAllPendingEvents(); /// Are there any pending tasks in the LO task queue? diff --git a/sc/source/core/tool/refreshtimer.cxx b/sc/source/core/tool/refreshtimer.cxx index cb83c4c..954c132 100644 --- a/sc/source/core/tool/refreshtimer.cxx +++ b/sc/source/core/tool/refreshtimer.cxx @@ -120,7 +120,7 @@ void ScRefreshTimer::Invoke() { // now we COULD make the call in another thread ... ::osl::MutexGuard aGuard( (*ppControl)->GetMutex() ); - maTimeoutHdl.Call( this ); + Timer::Invoke(); // restart from now on, don't execute immediately again if timed out // a second time during refresh if ( IsActive() ) diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 6809269..464ec9c 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -116,9 +116,6 @@ void Scheduler::ImplStartTimer( sal_uInt64 nMS ) pSVData->mpSalTimer->SetCallback(Scheduler::CallbackTaskScheduling); } - if ( !nMS ) - nMS = 1; - // Only if smaller timeout, to avoid skipping. if (nMS < pSVData->mnTimerPeriod) { @@ -152,7 +149,6 @@ inline void Scheduler::UpdateMinPeriod( ImplSchedulerData *pSchedulerData, { if ( nMinPeriod > ImmediateTimeoutMs ) pSchedulerData->mpScheduler->UpdateMinPeriod( nTime, nMinPeriod ); - assert( nMinPeriod >= ImmediateTimeoutMs ); } namespace @@ -171,7 +167,7 @@ bool Scheduler::HasPendingEvents() return lcl_HasPendingEvents( pSVData, nTime ); } -bool Scheduler::ProcessTaskScheduling() +bool Scheduler::ProcessTaskScheduling( IdleRunPolicy eIdleRunPolicy ) { ImplSVData* pSVData = ImplGetSVData(); sal_uInt64 nTime = tools::Time::GetSystemTicks(); @@ -237,8 +233,12 @@ next_entry: pMostUrgent->Invoke(); } - if ( nMinPeriod != InfiniteTimeoutMs ) + if ( nMinPeriod != InfiniteTimeoutMs + && ((eIdleRunPolicy == IdleRunPolicy::IDLE_VIA_TIMER) + || (nMinPeriod > ImmediateTimeoutMs)) ) + { ImplStartTimer( nMinPeriod ); + } else if ( pSVData->mpSalTimer ) pSVData->mpSalTimer->Stop(); diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index e6822db..ee9151d 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -532,14 +532,14 @@ void Application::Reschedule( bool i_bAllEvents ) void Scheduler::ProcessAllPendingEvents() { - int nSanity = 1000; - while( Scheduler::ProcessTaskScheduling() || - ImplYield(false, true, 0) ) + int nSanity = 1; + // nReleased == 1, because we don't run the LO event loop via timer + while( ImplYield( false, true, 1 ) + || Scheduler::ProcessTaskScheduling(IdleRunPolicy::IDLE_VIA_LOOP) ) { - if (nSanity-- < 0) + if (0 == ++nSanity % 1000) { - SAL_WARN("vcl.schedule", "Unexpected volume of events to process"); - break; + SAL_WARN("vcl.schedule", "ProcessAllPendingEvents: " << nSanity); } } } commit da4069f161c86c6f75faac4e593fdab386de95fb Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Wed Sep 14 13:48:02 2016 +0200 Change Idle to be a actually a Timer subclass Drops a lot of duplicated code and actually reflects the Scheduler handling of "idle" in the source code. Change-Id: I847592e92e86d15ab1cab168bf0e667322e48048 diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 6940fe4..6df0cb6 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -1343,7 +1343,7 @@ void EditorWindow::DestroyProgress() void EditorWindow::ForceSyntaxTimeout() { aSyntaxIdle.Stop(); - aSyntaxIdle.GetIdleHdl().Call(&aSyntaxIdle); + aSyntaxIdle.Invoke(); } // BreakPointWindow diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index e360c0a..fb126b4 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -810,7 +810,7 @@ void IdleFormattter::ForceTimeout() if ( IsActive() ) { Stop(); - ((Link<Idle *, void>&)GetIdleHdl()).Call( this ); + Invoke(); } } diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 17c106f..7b6e279 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -2683,8 +2683,7 @@ throw( uno::RuntimeException, std::exception ) m_bMustDoLayout = true; if ( !m_aAsyncLayoutTimer.IsActive() ) { - const Link<Timer *, void>& aLink = m_aAsyncLayoutTimer.GetTimeoutHdl(); - aLink.Call( &m_aAsyncLayoutTimer ); + m_aAsyncLayoutTimer.Invoke(); } if ( m_nLockCount == 0 ) m_aAsyncLayoutTimer.Start(); diff --git a/include/tools/link.hxx b/include/tools/link.hxx index f46e84e..ea8fe1a 100644 --- a/include/tools/link.hxx +++ b/include/tools/link.hxx @@ -102,6 +102,7 @@ public: { return function_ == other.function_ && instance_ == other.instance_; }; void *GetInstance() const { return instance_; } + Stub* GetFunction() const { return function_; } private: Stub * function_; diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx index f50e329..b290151 100644 --- a/include/vcl/idle.hxx +++ b/include/vcl/idle.hxx @@ -20,34 +20,47 @@ #ifndef INCLUDED_VCL_IDLE_HXX #define INCLUDED_VCL_IDLE_HXX -#include <tools/link.hxx> -#include <vcl/scheduler.hxx> +#include <vcl/timer.hxx> -class VCL_DLLPUBLIC Idle : public Scheduler +/** + * An idle is a low priority timer to be scheduled immediately. + * + * Therefore the timeout is set to ImmediateTimeoutMs and the initial, + * priority is DEFAULT_IDLE. + * + * It's - more or less - just a convenience class. + */ +class VCL_DLLPUBLIC Idle : public Timer { -protected: - Link<Idle *, void> maIdleHdl; // Callback Link - bool mbAuto; - - virtual void SetDeletionFlags() override; +private: + // Delete all timeout specific functions, we don't want in an Idle + void SetTimeout( sal_uInt64 nTimeoutMs ) = delete; + sal_uInt64 GetTimeout() const = delete; +protected: virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const override; virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const override; public: Idle( const sal_Char *pDebugName = nullptr ); - Idle( const Idle& rIdle ); - virtual void Start() override; + virtual void Start() override; - /// Make it possible to associate a callback with this idle handler - /// of course, you can also sub-class and override 'Invoke' - void SetIdleHdl( const Link<Idle *, void>& rLink ) { maIdleHdl = rLink; } - const Link<Idle *, void>& GetIdleHdl() const { return maIdleHdl; } - virtual void Invoke() override; - Idle& operator=( const Idle& rIdle ); + /** + * Convenience function for more readable code + * + * TODO: actually rename it and it's instances to SetInvokeHandler + */ + inline void SetIdleHdl( const Link<Idle *, void>& rLink ); }; +inline void Idle::SetIdleHdl( const Link<Idle*, void> &rLink ) +{ + SetInvokeHandler( Link<Timer*, void>( + static_cast<Timer*>( rLink.GetInstance() ), + reinterpret_cast< Link<Timer*, void>::Stub* >( rLink.GetFunction()) )); +} + /** * An auto-idle is long running task processing small chunks of data, which * is re-scheduled multiple times. @@ -61,8 +74,6 @@ class VCL_DLLPUBLIC AutoIdle : public Idle { public: AutoIdle( const sal_Char *pDebugName = nullptr ); - AutoIdle( const AutoIdle& rIdle ); - AutoIdle& operator=( const AutoIdle& rIdle ); }; #endif // INCLUDED_VCL_IDLE_HXX diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index 4f7e3d8..2cfa96a 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -26,9 +26,9 @@ class VCL_DLLPUBLIC Timer : public Scheduler { protected: - Link<Timer *, void> maTimeoutHdl; // Callback Link - sal_uInt64 mnTimeout; - bool mbAuto; + Link<Timer *, void> maInvokeHandler; ///< Callback Link + sal_uInt64 mnTimeout; + bool mbAuto; virtual void SetDeletionFlags() override; @@ -37,29 +37,45 @@ protected: public: Timer( const sal_Char *pDebugName = nullptr ); - Timer( const Timer& rTimer ); - /// Make it possible to associate a callback with this timer handler - /// of course, you can also sub-class and override 'Invoke' - void SetTimeoutHdl( const Link<Timer *, void>& rLink ) { maTimeoutHdl = rLink; } - const Link<Timer *, void>& GetTimeoutHdl() const { return maTimeoutHdl; } + /** + * Calls the maInvokeHandler with the parameter this. + */ + virtual void Invoke() override; + /** + * Calls the maInvokeHandler with the parameter. + * + * Convenience Invoke function, mainly used to call with nullptr. + * + * @param arg parameter for the Link::Call function + */ + void Invoke( Timer *arg ); + void SetInvokeHandler( const Link<Timer *, void>& rLink ) { maInvokeHandler = rLink; } + bool HasInvokeHandler() const { return maInvokeHandler.IsSet(); }; + + /** + * Convenience function for more readable code + * + * TODO: actually use SetInvokeHandler and drop it + */ + inline void SetTimeoutHdl( const Link<Timer *, void>& rLink ); + void SetTimeout( sal_uInt64 nTimeoutMs ); sal_uInt64 GetTimeout() const { return mnTimeout; } - virtual void Invoke() override; - void Timeout() { Invoke(); } - Timer& operator=( const Timer& rTimer ); virtual void Start() override; }; +inline void Timer::SetTimeoutHdl( const Link<Timer *, void>& rLink ) +{ + SetInvokeHandler( rLink ); +} + /// An auto-timer is a multi-shot timer re-emitting itself at /// interval until destroyed. class VCL_DLLPUBLIC AutoTimer : public Timer { public: - AutoTimer(); - AutoTimer( const AutoTimer& rTimer ); - - AutoTimer& operator=( const AutoTimer& rTimer ); + AutoTimer( const sal_Char *pDebugName = nullptr ); }; #endif // INCLUDED_VCL_TIMER_HXX diff --git a/solenv/gdb/libreoffice/vcl.py b/solenv/gdb/libreoffice/vcl.py index 13579a5..5f4e907 100644 --- a/solenv/gdb/libreoffice/vcl.py +++ b/solenv/gdb/libreoffice/vcl.py @@ -23,10 +23,11 @@ class ImplSchedulerDataPrinter(object): def as_string(self, gdbobj): if gdbobj['mpScheduler']: sched = gdbobj['mpScheduler'].dereference() - if gdbobj['mpScheduler'].dynamic_cast( self.timer_type_ptr ): - sched_type = "Timer" - elif gdbobj['mpScheduler'].dynamic_cast( self.idle_type_ptr ): + timer = gdbobj['mpScheduler'].dynamic_cast( self.timer_type_ptr ) + if gdbobj['mpScheduler'].dynamic_cast( self.idle_type_ptr ): sched_type = "Idle" + elif timer: + sched_type = "Timer" else: assert sched_type, "Scheduler object neither Timer nor Idle" res = "{:7s}{:10s}".format( sched_type, str(sched['mePriority']) ) @@ -35,6 +36,12 @@ class ImplSchedulerDataPrinter(object): res = "{} (scheduler debug name not set) ({})".format(res, str(sched.dynamic_type)) else: res = "{} '{}' ({})".format(res, str(name.string()), str(sched.dynamic_type)) + val_type = gdb.lookup_type(str( sched.dynamic_type )).pointer() + timer = gdbobj['mpScheduler'].cast( val_type ) + if (sched_type == "Timer"): + res = "{}: {}ms".format(res, timer['mnTimeout']) + else: + assert 0 == timer['mnTimeout'], "Idle with timeout == {}".format( timer['mnTimeout'] ) return res else: return "(no scheduler - to be deleted)" diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index 5224c77..f2c6264 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -20,42 +20,15 @@ #include <vcl/idle.hxx> #include "saltimer.hxx" -void Idle::SetDeletionFlags() -{ - // If no AutoIdle, then stop. - if ( !mbAuto ) - Scheduler::SetDeletionFlags(); -} - -void Idle::Invoke() -{ - maIdleHdl.Call( this ); -} - -Idle& Idle::operator=( const Idle& rIdle ) -{ - Scheduler::operator=(rIdle); - maIdleHdl = rIdle.maIdleHdl; - mbAuto = rIdle.mbAuto; - return *this; -} - Idle::Idle( const sal_Char *pDebugName ) - : Scheduler( pDebugName ) - , mbAuto( false ) + : Timer( pDebugName ) { mePriority = SchedulerPriority::DEFAULT_IDLE; } -Idle::Idle( const Idle& rIdle ) : Scheduler(rIdle) -{ - maIdleHdl = rIdle.maIdleHdl; - mbAuto = rIdle.mbAuto; -} - void Idle::Start() { - Scheduler::Start(); + Timer::Start(); sal_uInt64 nPeriod = Scheduler::ImmediateTimeoutMs; if (Scheduler::GetDeterministicMode()) @@ -88,17 +61,7 @@ void Idle::UpdateMinPeriod( const sal_uInt64 /* nTime */, sal_uInt64 &nMinPeriod AutoIdle::AutoIdle( const sal_Char *pDebugName ) : Idle( pDebugName ) { -} - -AutoIdle::AutoIdle( const AutoIdle& rIdle ) : Idle( rIdle ) -{ mbAuto = true; } -AutoIdle& AutoIdle::operator=( const AutoIdle& rIdle ) -{ - Idle::operator=( rIdle ); - return *this; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index 8a30fe1..8e02235 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -46,25 +46,22 @@ void Timer::UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) co } } -Timer::Timer(const sal_Char *pDebugName) : - Scheduler(pDebugName), - mnTimeout(ImmediateTimeoutMs), - mbAuto(false) +Timer::Timer(const sal_Char *pDebugName) + : Scheduler( pDebugName ) + , mnTimeout( ImmediateTimeoutMs ) + , mbAuto( false ) { mePriority = SchedulerPriority::DEFAULT; } -Timer::Timer( const Timer& rTimer ) : - Scheduler(rTimer), - mnTimeout(rTimer.mnTimeout), - mbAuto(rTimer.mbAuto) +void Timer::Invoke() { - maTimeoutHdl = rTimer.maTimeoutHdl; + maInvokeHandler.Call( this ); } -void Timer::Invoke() +void Timer::Invoke( Timer *arg ) { - maTimeoutHdl.Call( this ); + maInvokeHandler.Call( arg ); } void Timer::Start() @@ -83,28 +80,10 @@ void Timer::SetTimeout( sal_uInt64 nNewTimeout ) } } -Timer& Timer::operator=( const Timer& rTimer ) -{ - Scheduler::operator=(rTimer); - maTimeoutHdl = rTimer.maTimeoutHdl; - mnTimeout = rTimer.mnTimeout; - mbAuto = rTimer.mbAuto; - return *this; -} - -AutoTimer::AutoTimer() +AutoTimer::AutoTimer( const sal_Char *pDebugName ) + : Timer( pDebugName ) { mbAuto = true; } -AutoTimer::AutoTimer( const AutoTimer& rTimer ) : Timer( rTimer ) -{ - mbAuto = true; -} - -AutoTimer& AutoTimer::operator=( const AutoTimer& rTimer ) -{ - Timer::operator=( rTimer ); - return *this; -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index d1b4601..526e4ea 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -1923,7 +1923,7 @@ void Edit::LoseFocus() { //notify an update latest when the focus is lost mpUpdateDataTimer->Stop(); - mpUpdateDataTimer->Timeout(); + mpUpdateDataTimer->Invoke(); } if ( !mpSubEdit ) diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index 7974f52..cd4413c 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -293,7 +293,7 @@ void IdleFormatter::DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts ) if ( mnRestarts > nMaxRestarts ) { mnRestarts = 0; - ((Link<Idle *, void>&)GetIdleHdl()).Call( this ); + Invoke(); } else { @@ -307,7 +307,7 @@ void IdleFormatter::ForceTimeout() { Stop(); mnRestarts = 0; - ((Link<Idle *, void>&)GetIdleHdl()).Call( this ); + Invoke(); } } diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index d441f07..716aea3 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -686,7 +686,7 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void) if( mpWindowImpl->mpFrameData->maPaintIdle.IsActive() ) { mpWindowImpl->mpFrameData->maPaintIdle.Stop(); - mpWindowImpl->mpFrameData->maPaintIdle.GetIdleHdl().Call( nullptr ); + mpWindowImpl->mpFrameData->maPaintIdle.Invoke( nullptr ); } } } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 2e1b9d5..5ee3763 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -2395,7 +2395,7 @@ Size Window::GetSizePixel() const { VclPtr<vcl::Window> xWindow( const_cast<Window*>(this) ); mpWindowImpl->mpFrameData->maResizeIdle.Stop(); - mpWindowImpl->mpFrameData->maResizeIdle.GetIdleHdl().Call( nullptr ); + mpWindowImpl->mpFrameData->maResizeIdle.Invoke( nullptr ); if( xWindow->IsDisposed() ) return Size(0,0); } commit 3a3ddf87ff9f3cb49c5219316de099f79e6315ff Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Mon Sep 12 18:24:14 2016 +0200 Handle all main loop and task events Change-Id: I75ed5a38b0e24966dafcfdd2ea4cb8afc93a8a0c diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index a1df962..e6822db 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -506,7 +506,14 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased if (nReleased == 0) // tdf#99383 don't run stuff from ReAcquireSolarMutex { // Process all Tasks - bProcessedEvent = Scheduler::ProcessTaskScheduling() || bProcessedEvent; + do + { + bool bScheduledEevent = Scheduler::ProcessTaskScheduling(); + bProcessedEvent = bProcessedEvent || bScheduledEevent; + if (!bScheduledEevent) + break; + } + while ( i_bAllEvents ); } // flush lazy deleted objects commit 26d3173af4b1230544ba2fe66f0841568154cfb5 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Wed Aug 10 12:00:53 2016 +0200 Reorganize Scheduler priority classes This is based on glibs classification of tasks, but while glib uses an int for more fine grained priority, we stay with our enum. 1. Timers start with DEFAULT priority, which directly corresponds with the previous HIGH priority 2. Idles start with DEFAULT_IDLE priority instead of the previous HIGH priority, so idle default becomes "really run when idle". As RESIZE and REPAINT are special, and the DEFAULTS are set, there is just one primary decision for the programmer: should my idle run before paint (AKA HIGH_IDLE)? If we really need a more fine-grained classification, we can add it later, or also switch to a real int. As a result, this drops many classifications from the code and drastically changes behaviour, AKA a mail merge from KDE is now as fast as Gtk+ again. Conflicts: cui/source/tabpages/macroass.cxx desktop/source/deployment/gui/dp_gui_dialog2.cxx include/vcl/scheduler.hxx sc/source/core/tool/dbdata.cxx sc/source/ui/formdlg/dwfunctr.cxx sc/source/ui/miscdlgs/anyrefdg.cxx sd/source/ui/dlg/dlgass.cxx sd/source/ui/slideshow/slideshowimpl.cxx svx/source/inc/eventhandler.hxx svx/source/sdr/overlay/overlaymanagerbuffered.cxx sw/source/uibase/docvw/srcedtw.cxx sw/source/uibase/utlui/unotools.cxx vcl/source/app/idle.cxx vcl/source/app/scheduler.cxx vcl/source/app/timer.cxx Change-Id: I498a73fd02d5fb6f5d7e9f742f3bce972de9b1f9 diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx index b2c12c0..958e68e 100644 --- a/avmedia/source/framework/mediacontrol.cxx +++ b/avmedia/source/framework/mediacontrol.cxx @@ -114,7 +114,7 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl mpZoomToolBox->SetPaintTransparent( true ); } - maIdle.SetPriority( SchedulerPriority::LOW ); + maIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); maIdle.SetIdleHdl( LINK( this, MediaControl, implTimeoutHdl ) ); maIdle.Start(); } diff --git a/avmedia/source/framework/soundhandler.cxx b/avmedia/source/framework/soundhandler.cxx index 785f6ce..d4a63ef 100644 --- a/avmedia/source/framework/soundhandler.cxx +++ b/avmedia/source/framework/soundhandler.cxx @@ -221,7 +221,7 @@ void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL& // Count this request and initialize self-holder against dying by uno ref count ... m_xSelfHold.set(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY); m_xPlayer->start(); - m_aUpdateIdle.SetPriority( SchedulerPriority::LOWER ); + m_aUpdateIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); m_aUpdateIdle.Start(); } catch( css::uno::Exception& e ) diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx index 4077e3b..358dac7 100644 --- a/avmedia/source/opengl/oglplayer.cxx +++ b/avmedia/source/opengl/oglplayer.cxx @@ -123,7 +123,7 @@ bool OGLPlayer::create( const OUString& rURL ) // Set timer m_aTimer.SetTimeout(8); // is 125fps enough for anyone ? - m_aTimer.SetPriority(SchedulerPriority::LOW); + m_aTimer.SetPriority(SchedulerPriority::HIGH_IDLE); m_aTimer.SetTimeoutHdl(LINK(this,OGLPlayer,TimerHandler)); return true; diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index e511f74..6940fe4 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -961,7 +961,6 @@ void EditorWindow::CreateEditEngine() ImplSetFont(); - aSyntaxIdle.SetPriority( SchedulerPriority::LOWER ); aSyntaxIdle.SetIdleHdl( LINK( this, EditorWindow, SyntaxTimerHdl ) ); bool bWasDoSyntaxHighlight = bDoSyntaxHighlight; diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 157a2eb..6d9a150 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -218,7 +218,6 @@ DlgEditor::DlgEditor ( m_ClipboardDataFlavorsResource[1].HumanPresentableName = "Dialog 8.0" ; m_ClipboardDataFlavorsResource[1].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aMarkIdle.SetPriority(SchedulerPriority::LOW); aMarkIdle.SetIdleHdl( LINK( this, DlgEditor, MarkTimeout ) ); rWindow.SetMapMode( MapMode( MAP_100TH_MM ) ); diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx index 70db945..83f70b9 100644 --- a/cui/source/options/optjava.cxx +++ b/cui/source/options/optjava.cxx @@ -186,7 +186,6 @@ SvxJavaOptionsPage::SvxJavaOptionsPage( vcl::Window* pParent, const SfxItemSet& m_pParameterBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ParameterHdl_Impl ) ); m_pClassPathBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ClassPathHdl_Impl ) ); m_aResetIdle.SetIdleHdl( LINK( this, SvxJavaOptionsPage, ResetHdl_Impl ) ); - m_aResetIdle.SetPriority(SchedulerPriority::LOWER); m_pExpertConfigBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ExpertConfigHdl_Impl) ); if (!officecfg::Office::Common::Security::EnableExpertConfiguration::get()) diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx index bb4ede3..97d293b 100644 --- a/cui/source/tabpages/macroass.cxx +++ b/cui/source/tabpages/macroass.cxx @@ -138,7 +138,7 @@ SfxMacroTabPage::SfxMacroTabPage(vcl::Window* pParent, const Reference< XFrame > mpImpl.reset(new SfxMacroTabPage_Impl); mpImpl->maFillGroupIdle.SetIdleHdl( LINK( this, SfxMacroTabPage, TimeOut_Impl ) ); - mpImpl->maFillGroupIdle.SetPriority( SchedulerPriority::HIGHEST ); + mpImpl->maFillGroupIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); mpImpl->maFillGroupIdle.SetDebugName( "SfxMacroTabPage maFillGroupIdle" ); mpImpl->sStrEvent = get<FixedText>("eventft")->GetText(); diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 657582f..ff429b7 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -1063,7 +1063,7 @@ void OJoinTableView::ScrollWhileDragging() // resetting timer, if still necessary if (bNeedScrollTimer) { - m_aDragScrollIdle.SetPriority(SchedulerPriority::LOW); + m_aDragScrollIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); m_aDragScrollIdle.Start(); } diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 7c14fb3..99ee193 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -1202,7 +1202,6 @@ UpdateRequiredDialog::UpdateRequiredDialog(vcl::Window *pParent, TheExtensionMan m_pUpdateBtn->Enable( false ); m_pCloseBtn->GrabFocus(); - m_aIdle.SetPriority( SchedulerPriority::LOWEST ); m_aIdle.SetIdleHdl( LINK( this, UpdateRequiredDialog, TimeOutHdl ) ); } diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx index 6173a5a..cd2f88f 100644 --- a/formula/source/ui/dlg/formula.cxx +++ b/formula/source/ui/dlg/formula.cxx @@ -1803,7 +1803,6 @@ OUString FormulaDlg::GetMeText() const void FormulaDlg::Update() { m_pImpl->Update(); - m_pImpl->aIdle.SetPriority(SchedulerPriority::LOWER); m_pImpl->aIdle.SetIdleHdl(LINK( this, FormulaDlg, UpdateFocusHdl)); m_pImpl->aIdle.Start(); } diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx index d67bb00..6168fc4 100644 --- a/formula/source/ui/dlg/funcutl.cxx +++ b/formula/source/ui/dlg/funcutl.cxx @@ -435,7 +435,6 @@ RefEdit::RefEdit( vcl::Window* _pParent, vcl::Window* pShrinkModeLabel, WinBits , pLabelWidget(pShrinkModeLabel) { aIdle.SetIdleHdl( LINK( this, RefEdit, UpdateHdl ) ); - aIdle.SetPriority( SchedulerPriority::LOW ); } RefEdit::RefEdit( vcl::Window* _pParent,IControlReferenceHandler* pParent, @@ -446,7 +445,6 @@ RefEdit::RefEdit( vcl::Window* _pParent,IControlReferenceHandler* pParent, , pLabelWidget(pShrinkModeLabel) { aIdle.SetIdleHdl( LINK( this, RefEdit, UpdateHdl ) ); - aIdle.SetPriority( SchedulerPriority::LOW ); } VCL_BUILDER_DECL_FACTORY(RefEdit) @@ -515,7 +513,6 @@ void RefEdit::SetReferences( IControlReferenceHandler* pDlg, vcl::Window* pLabel if( pDlg ) { aIdle.SetIdleHdl( LINK( this, RefEdit, UpdateHdl ) ); - aIdle.SetPriority( SchedulerPriority::LOW ); } else { diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx index 36985e8..0f72b99 100644 --- a/include/vcl/scheduler.hxx +++ b/include/vcl/scheduler.hxx @@ -25,16 +25,14 @@ struct ImplSchedulerData; enum class SchedulerPriority { - HIGHEST = 0, - HIGH = 1, - RESIZE = 2, - REPAINT = 3, - MEDIUM = 3, - POST_PAINT = 4, - DEFAULT_IDLE = 5, - LOW = 6, - LOWER = 7, - LOWEST = 8 + HIGHEST, ///< These events should run very fast! + DEFAULT, ///< Default priority used, e.g. the default timer priority + HIGH_IDLE, ///< Important idle events to be run before processing drawing events + RESIZE, ///< Resize runs before repaint, so we won't paint twice + REPAINT, ///< All repaint events should go in here + POST_PAINT, ///< Everything running directly after painting + DEFAULT_IDLE, ///< Default idle priority + LOWEST ///< Low, very idle cleanup tasks }; class VCL_DLLPUBLIC Scheduler diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx index c5d2974..cd4230d 100644 --- a/reportdesign/source/ui/report/DesignView.cxx +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -117,7 +117,6 @@ ODesignView::ODesignView( vcl::Window* pParent, m_aSplitWin->SetAlign(WindowAlign::Left); m_aSplitWin->Show(); - m_aMarkIdle.SetPriority( SchedulerPriority::LOW ); m_aMarkIdle.SetIdleHdl( LINK( this, ODesignView, MarkTimeout ) ); } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index dddcde6..762da40 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -247,7 +247,6 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : SetLanguage( ScGlobal::eLnge, ScGlobal::eLnge, ScGlobal::eLnge ); aTrackIdle.SetIdleHdl( LINK( this, ScDocument, TrackTimeHdl ) ); - aTrackIdle.SetPriority( SchedulerPriority::LOW ); } sfx2::LinkManager* ScDocument::GetLinkManager() diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index d06ed71..6f7d981 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -176,7 +176,6 @@ ScModule::ScModule( SfxObjectFactory* pFact ) : ERRCODE_AREA_APP2-1, GetResMgr() ); - aSpellIdle.SetPriority(SchedulerPriority::LOWER); aSpellIdle.SetIdleHdl( LINK( this, ScModule, SpellTimerHdl ) ); aSpellIdle.SetDebugName( "sc::ScModule aSpellIdle" ); diff --git a/sc/source/ui/docshell/autostyl.cxx b/sc/source/ui/docshell/autostyl.cxx index 463b88b..db7a400 100644 --- a/sc/source/ui/docshell/autostyl.cxx +++ b/sc/source/ui/docshell/autostyl.cxx @@ -65,7 +65,7 @@ ScAutoStyleList::ScAutoStyleList(ScDocShell* pShell) { aTimer.SetTimeoutHdl( LINK( this, ScAutoStyleList, TimerHdl ) ); aInitIdle.SetIdleHdl( LINK( this, ScAutoStyleList, InitHdl ) ); - aInitIdle.SetPriority( SchedulerPriority::HIGHEST ); + aInitIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); } ScAutoStyleList::~ScAutoStyleList() diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx index 8a36f6d..b30765ed 100644 --- a/sc/source/ui/formdlg/dwfunctr.cxx +++ b/sc/source/ui/formdlg/dwfunctr.cxx @@ -70,7 +70,6 @@ ScFunctionWin::ScFunctionWin( SfxBindings* pBindingsP, vcl::Window* pParent, con InitLRUList(); SetStyle(GetStyle()|WB_CLIPCHILDREN); - aIdle.SetPriority(SchedulerPriority::LOWER); aIdle.SetIdleHdl(LINK( this, ScFunctionWin, TimerHdl)); aFiFuncDesc->SetUpdateMode(true); diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index e52abbd..17764ae 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -108,13 +108,11 @@ ScAcceptChgDlg::ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window m_pAcceptChgCtr = VclPtr<SvxAcceptChgCtr>::Create(get_content_area(), this); nAcceptCount=0; nRejectCount=0; - aReOpenIdle.SetPriority(SchedulerPriority::MEDIUM); aReOpenIdle.SetIdleHdl(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl )); pTPFilter=m_pAcceptChgCtr->GetFilterPage(); pTPView=m_pAcceptChgCtr->GetViewPage(); pTheView=pTPView->GetTableControl(); - aSelectionIdle.SetPriority(SchedulerPriority::LOW); aSelectionIdle.SetIdleHdl(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl )); aSelectionIdle.SetDebugName( "ScAcceptChgDlg aSelectionIdle" ); diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index 63e6cef..a80c61e 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -765,7 +765,6 @@ ScRefHandler::ScRefHandler( vcl::Window &rWindow, SfxBindings* pB, bool bBindRef pActiveWin(nullptr) { m_aHelper.SetWindow(m_rWindow.get()); - aIdle.SetPriority(SchedulerPriority::LOWER); aIdle.SetIdleHdl(LINK( this, ScRefHandler, UpdateFocusHdl)); if( bBindRef ) EnterRefMode(); diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx index 99abeb3..e2ee2a8 100644 --- a/sc/source/ui/miscdlgs/conflictsdlg.cxx +++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx @@ -421,7 +421,6 @@ ScConflictsDlg::ScConflictsDlg( vcl::Window* pParent, ScViewData* pViewData, ScD m_pLbConflicts->SetSelectionMode( SelectionMode::Multiple ); m_pLbConflicts->SetHighlightRange(); - maSelectionIdle.SetPriority( SchedulerPriority::LOW ); maSelectionIdle.SetIdleHdl( LINK( this, ScConflictsDlg, UpdateSelectionHdl ) ); maSelectionIdle.SetDebugName( "ScConflictsDlg maSelectionIdle" ); diff --git a/sd/source/ui/dlg/filedlg.cxx b/sd/source/ui/dlg/filedlg.cxx index 9fa35bb..c3cf3c7 100644 --- a/sd/source/ui/dlg/filedlg.cxx +++ b/sd/source/ui/dlg/filedlg.cxx @@ -129,7 +129,6 @@ IMPL_LINK_NOARG_TYPED(SdFileDialog_Imp, PlayMusicHdl, void*, void) { mxPlayer.set( avmedia::MediaWindow::createPlayer( aUrl, "" ), css::uno::UNO_QUERY_THROW ); mxPlayer->start(); - maUpdateIdle.SetPriority( SchedulerPriority::LOW ); maUpdateIdle.Start(); } catch (const css::uno::Exception&) diff --git a/sd/source/ui/framework/module/ShellStackGuard.cxx b/sd/source/ui/framework/module/ShellStackGuard.cxx index a37cf5f..eea14db 100644 --- a/sd/source/ui/framework/module/ShellStackGuard.cxx +++ b/sd/source/ui/framework/module/ShellStackGuard.cxx @@ -72,7 +72,6 @@ ShellStackGuard::ShellStackGuard (Reference<frame::XController>& rxController) // Prepare the printer polling. maPrinterPollingIdle.SetIdleHdl(LINK(this,ShellStackGuard,TimeoutHandler)); - maPrinterPollingIdle.SetPriority(SchedulerPriority::LOWER); } } diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index ebb545b..741a1c5 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -143,9 +143,7 @@ View::View(SdDrawDocument& rDrawDoc, OutputDevice* pOutDev, // Timer for delayed drop (has to be for MAC) maDropErrorIdle.SetIdleHdl( LINK(this, View, DropErrorHdl) ); - maDropErrorIdle.SetPriority(SchedulerPriority::MEDIUM); maDropInsertFileIdle.SetIdleHdl( LINK(this, View, DropInsertFileHdl) ); - maDropInsertFileIdle.SetPriority(SchedulerPriority::MEDIUM); } void View::ImplClearDrawDropMarker() diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index bef93b6..d830482 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -111,7 +111,7 @@ SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint& rHint ) StartListening( *rHint.GetObjShell() ); pIdle = new Idle("SfxEventASyncer"); pIdle->SetIdleHdl( LINK(this, SfxEventAsyncer_Impl, IdleHdl) ); - pIdle->SetPriority( SchedulerPriority::HIGHEST ); + pIdle->SetPriority( SchedulerPriority::HIGH_IDLE ); pIdle->SetDebugName( "sfx::SfxEventAsyncer_Impl pIdle" ); pIdle->Start(); } diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 9ff07b0..0196c1a 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -553,7 +553,6 @@ IndexTabPage_Impl::IndexTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Im m_pOpenBtn->SetClickHdl( LINK( this, IndexTabPage_Impl, OpenHdl ) ); Link<Timer *, void> aTimeoutLink = LINK( this, IndexTabPage_Impl, TimeoutHdl ); aFactoryIdle.SetIdleHdl( LINK(this, IndexTabPage_Impl, IdleHdl )); - aFactoryIdle.SetPriority(SchedulerPriority::LOWER); aKeywordTimer.SetTimeoutHdl( aTimeoutLink ); } @@ -1434,7 +1433,6 @@ SfxHelpIndexWindow_Impl::SfxHelpIndexWindow_Impl(SfxHelpWindow_Impl* _pParent) nMinWidth = ( m_pActiveLB->GetSizePixel().Width() / 2 ); aIdle.SetIdleHdl( LINK( this, SfxHelpIndexWindow_Impl, InitHdl ) ); - aIdle.SetPriority( SchedulerPriority::LOWER ); aIdle.Start(); Show(); diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 68c23f4..3cbacc8 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -453,7 +453,7 @@ void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent ) xImp->xPoster = new SfxHintPoster(aGenLink); - xImp->aIdle.SetPriority(SchedulerPriority::MEDIUM); + xImp->aIdle.SetPriority(SchedulerPriority::HIGH_IDLE ); xImp->aIdle.SetIdleHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) ); xImp->aIdle.SetDebugName( "sfx::SfxDispatcher_Impl aIdle" ); } @@ -590,8 +590,6 @@ void SfxDispatcher::Pop(SfxShell& rShell, SfxDispatcherPopFlags nMode) if(!pSfxApp->IsDowning() && !xImp->aToDoStack.empty()) { // No immediate update is requested - xImp->aIdle.SetPriority(SchedulerPriority::MEDIUM); - xImp->aIdle.SetIdleHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) ); xImp->aIdle.Start(); } else @@ -793,8 +791,6 @@ void SfxDispatcher::DoActivate_Impl(bool bMDI) if(!xImp->aToDoStack.empty()) { // No immediate update is requested - xImp->aIdle.SetPriority(SchedulerPriority::MEDIUM); - xImp->aIdle.SetIdleHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) ); xImp->aIdle.Start(); } } diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index aece5b3..b9b6217 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -143,7 +143,7 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl( aEditIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,EditTimeoutHdl)); aEditIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aEditIdle" ); - aAutoArrangeIdle.SetPriority( SchedulerPriority::LOW ); + aAutoArrangeIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); aAutoArrangeIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,AutoArrangeHdl)); aAutoArrangeIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aAutoArrangeIdle" ); @@ -151,11 +151,11 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl( aCallSelectHdlIdle.SetIdleHdl( LINK(this,SvxIconChoiceCtrl_Impl,CallSelectHdlHdl)); aCallSelectHdlIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aCallSelectHdlIdle" ); - aDocRectChangedIdle.SetPriority( SchedulerPriority::MEDIUM ); + aDocRectChangedIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); aDocRectChangedIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,DocRectChangedHdl)); aDocRectChangedIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aDocRectChangedIdle" ); - aVisRectChangedIdle.SetPriority( SchedulerPriority::MEDIUM ); + aVisRectChangedIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); aVisRectChangedIdle.SetIdleHdl(LINK(this,SvxIconChoiceCtrl_Impl,VisRectChangedHdl)); aVisRectChangedIdle.SetDebugName( "svtools::SvxIconChoiceCtrl_Impl aVisRectChangedIdle" ); diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index d364a3b..672e35c 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -89,7 +89,7 @@ SvImpLBox::SvImpLBox( SvTreeListBox* pLBView, SvTreeList* pLBTree, WinBits nWinS nNodeBmpWidth = 0; bAsyncBeginDrag = false; - aAsyncBeginDragIdle.SetPriority( SchedulerPriority::HIGHEST ); + aAsyncBeginDragIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); aAsyncBeginDragIdle.SetIdleHdl( LINK(this,SvImpLBox,BeginDragHdl)); // button animation in listbox pActiveButton = nullptr; diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx index 6e072e6..3b34c32 100644 --- a/svx/source/dialog/_contdlg.cxx +++ b/svx/source/dialog/_contdlg.cxx @@ -286,7 +286,6 @@ SvxSuperContourDlg::SvxSuperContourDlg(SfxBindings *_pBindings, SfxChildWindow * Resize(); - aUpdateIdle.SetPriority( SchedulerPriority::LOW ); aUpdateIdle.SetIdleHdl( LINK( this, SvxSuperContourDlg, UpdateHdl ) ); aCreateIdle.SetPriority( SchedulerPriority::RESIZE ); diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx index c3f46e6..61dea55 100644 --- a/svx/source/dialog/imapdlg.cxx +++ b/svx/source/dialog/imapdlg.cxx @@ -203,7 +203,6 @@ SvxIMapDlg::SvxIMapDlg(SfxBindings *_pBindings, SfxChildWindow *pCW, vcl::Window m_pCbbTarget->Disable(); pOwnData->bExecState = false; - pOwnData->aIdle.SetPriority( SchedulerPriority::LOW ); pOwnData->aIdle.SetIdleHdl( LINK( this, SvxIMapDlg, UpdateHdl ) ); m_pTbxIMapDlg1->EnableItem( mnActiveId, false ); diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx index efeaad6..57fdc7e 100644 --- a/svx/source/sdr/contact/objectcontactofpageview.cxx +++ b/svx/source/sdr/contact/objectcontactofpageview.cxx @@ -61,7 +61,7 @@ namespace sdr setPreviewRenderer(((SdrPaintView&)rPageWindow.GetPageView().GetView()).IsPreviewRenderer()); // init timer - SetPriority(SchedulerPriority::HIGH); + SetPriority(SchedulerPriority::HIGH_IDLE); Stop(); } diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx index 4827c3d..dc274cd 100644 --- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx @@ -84,7 +84,7 @@ PagePrimitiveExtractor::PagePrimitiveExtractor( setPreviewRenderer(true); // init timer - SetPriority(SchedulerPriority::HIGH); + SetPriority(SchedulerPriority::HIGH_IDLE); Stop(); } diff --git a/svx/source/sdr/event/eventhandler.cxx b/svx/source/sdr/event/eventhandler.cxx index 681d9cf..4588972 100644 --- a/svx/source/sdr/event/eventhandler.cxx +++ b/svx/source/sdr/event/eventhandler.cxx @@ -83,7 +83,7 @@ namespace sdr TimerEventHandler::TimerEventHandler() { - SetPriority(SchedulerPriority::HIGH); + SetPriority(SchedulerPriority::HIGH_IDLE); Stop(); } diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx index 51e6f47..40ed111 100644 --- a/svx/source/svdraw/svdibrow.cxx +++ b/svx/source/svdraw/svdibrow.cxx @@ -1101,7 +1101,7 @@ void SdrItemBrowser::SetDirty() { if (!bDirty) { bDirty = true; - aIdle.SetPriority(SchedulerPriority::HIGH); + aIdle.SetPriority(SchedulerPriority::HIGH_IDLE); aIdle.Start(); } } diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index 7c066c8..90cddd8 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -121,7 +121,6 @@ ImplGrafMetricField::ImplGrafMetricField( vcl::Window* pParent, const OUString& SetSpinSize( 1 ); } - maIdle.SetPriority( SchedulerPriority::LOW ); maIdle.SetIdleHdl( LINK( this, ImplGrafMetricField, ImplModifyHdl ) ); } diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx index 6b34e90..a566e87 100644 --- a/sw/source/uibase/docvw/srcedtw.cxx +++ b/sw/source/uibase/docvw/srcedtw.cxx @@ -535,7 +535,6 @@ void SwSrcEditWindow::CreateTextEngine() m_pOutWin->SetFont( aFont ); m_pTextEngine->SetFont( aFont ); - m_aSyntaxIdle.SetPriority( SchedulerPriority::LOWER ); m_aSyntaxIdle.SetIdleHdl( LINK( this, SwSrcEditWindow, SyntaxTimerHdl ) ); m_pTextEngine->EnableUndo( true ); diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx index 219823f..6e90ac2 100644 --- a/sw/source/uibase/utlui/unotools.cxx +++ b/sw/source/uibase/utlui/unotools.cxx @@ -84,7 +84,7 @@ SwOneExampleFrame::SwOneExampleFrame( vcl::Window& rWin, // the controller is asynchronously set aLoadedIdle.SetIdleHdl(LINK(this, SwOneExampleFrame, TimeoutHdl)); - aLoadedIdle.SetPriority(SchedulerPriority::HIGH); + aLoadedIdle.SetPriority(SchedulerPriority::HIGH_IDLE); CreateControl(); diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index 1fe9819..5224c77 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -44,6 +44,7 @@ Idle::Idle( const sal_Char *pDebugName ) : Scheduler( pDebugName ) , mbAuto( false ) { + mePriority = SchedulerPriority::DEFAULT_IDLE; } Idle::Idle( const Idle& rIdle ) : Scheduler(rIdle) @@ -61,8 +62,7 @@ void Idle::Start() { switch (mePriority) { - case SchedulerPriority::LOW: - case SchedulerPriority::LOWER: + case SchedulerPriority::DEFAULT_IDLE: case SchedulerPriority::LOWEST: nPeriod = Scheduler::InfiniteTimeoutMs; break; @@ -82,7 +82,7 @@ bool Idle::ReadyForSchedule( const sal_uInt64 /* nTime */ ) const void Idle::UpdateMinPeriod( const sal_uInt64 /* nTime */, sal_uInt64 &nMinPeriod ) const { - nMinPeriod = ImmediateTimeoutMs; + nMinPeriod = ImmediateTimeoutMs; // don't wait } AutoIdle::AutoIdle( const sal_Char *pDebugName ) diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 95e41c5..6809269 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -313,7 +313,7 @@ Scheduler& Scheduler::operator=( const Scheduler& rScheduler ) Scheduler::Scheduler(const sal_Char *pDebugName): mpSchedulerData(nullptr), mpDebugName(pDebugName), - mePriority(SchedulerPriority::HIGH) + mePriority(SchedulerPriority::DEFAULT) { } diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 643f836..a1df962 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -463,7 +463,7 @@ void Application::Execute() pSVData->maAppData.mnEventTestLimit = 50; pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting"); pSVData->maAppData.mpEventTestingIdle->SetIdleHdl(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl)); - pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::MEDIUM); + pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::HIGH_IDLE); pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ); pSVData->maAppData.mpEventTestingIdle->Start(); } diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index fb5d382..8a30fe1 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -51,7 +51,7 @@ Timer::Timer(const sal_Char *pDebugName) : mnTimeout(ImmediateTimeoutMs), mbAuto(false) { - mePriority = SchedulerPriority::HIGHEST; + mePriority = SchedulerPriority::DEFAULT; } Timer::Timer( const Timer& rTimer ) : diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index cc7e79a..7974f52 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -275,7 +275,7 @@ IdleFormatter::IdleFormatter() { mpView = nullptr; mnRestarts = 0; - SetPriority(SchedulerPriority::HIGH); + SetPriority(SchedulerPriority::HIGH_IDLE); } IdleFormatter::~IdleFormatter() diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx index 0bd29c9..78769e14 100644 --- a/vcl/source/window/dockmgr.cxx +++ b/vcl/source/window/dockmgr.cxx @@ -90,11 +90,11 @@ ImplDockFloatWin2::ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits, SetBackground( GetSettings().GetStyleSettings().GetFaceColor() ); maDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin2, DockTimerHdl ) ); - maDockIdle.SetPriority( SchedulerPriority::MEDIUM ); + maDockIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); maDockIdle.SetDebugName( "vcl::ImplDockFloatWin2 maDockIdle" ); maEndDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) ); - maEndDockIdle.SetPriority( SchedulerPriority::MEDIUM ); + maEndDockIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); maEndDockIdle.SetDebugName( "vcl::ImplDockFloatWin2 maEndDockIdle" ); } diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx index f35f68e..c2e7206 100644 --- a/vcl/source/window/dockwin.cxx +++ b/vcl/source/window/dockwin.cxx @@ -106,7 +106,7 @@ ImplDockFloatWin::ImplDockFloatWin( vcl::Window* pParent, WinBits nWinBits, SetBackground(); maDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin, DockTimerHdl ) ); - maDockIdle.SetPriority( SchedulerPriority::MEDIUM ); + maDockIdle.SetPriority( SchedulerPriority::HIGH_IDLE ); maDockIdle.SetDebugName( "vcl::ImplDockFloatWin maDockIdle" ); } commit ad36b09035e9d4653d0208433540cb1d961e06ec Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Tue Sep 13 12:20:45 2016 +0200 Don't wait in Yield with pending events This re-introduces some functionality of commit 87199d3829257420429057336283c55be6ae7481 I'm not sure, if we really want to skip the wait on pendig events. Change-Id: Ie88c2945acb066e312bab7d0f5b2f3b525fa1c4c diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx index 47ce27c..36985e8 100644 --- a/include/vcl/scheduler.hxx +++ b/include/vcl/scheduler.hxx @@ -89,6 +89,8 @@ public: static bool ProcessTaskScheduling(); /// Process all events until we are idle static void ProcessAllPendingEvents(); + /// Are there any pending tasks in the LO task queue? + static bool HasPendingEvents(); /// Control the deterministic mode. In this mode, two subsequent runs of /// LibreOffice fire about the same amount idles. diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 7df76bc..95e41c5 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -155,12 +155,27 @@ inline void Scheduler::UpdateMinPeriod( ImplSchedulerData *pSchedulerData, assert( nMinPeriod >= ImmediateTimeoutMs ); } +namespace +{ + inline bool lcl_HasPendingEvents( const ImplSVData* pSVData, const sal_uInt64 nTime ) + { + return (pSVData->mbNeedsReschedule || + (nTime >= pSVData->mnLastUpdate + pSVData->mnTimerPeriod) ); + } +} + +bool Scheduler::HasPendingEvents() +{ + ImplSVData* pSVData = ImplGetSVData(); + sal_uInt64 nTime = tools::Time::GetSystemTicks(); + return lcl_HasPendingEvents( pSVData, nTime ); +} + bool Scheduler::ProcessTaskScheduling() { ImplSVData* pSVData = ImplGetSVData(); sal_uInt64 nTime = tools::Time::GetSystemTicks(); - if (!pSVData->mbNeedsReschedule && - (nTime < pSVData->mnLastUpdate + pSVData->mnTimerPeriod) ) + if ( !lcl_HasPendingEvents( pSVData, nTime ) ) return false; pSVData->mbNeedsReschedule = false; diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index c3917da..643f836 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -481,6 +481,9 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased SAL_INFO("vcl.schedule", "Enter ImplYield: " << (i_bWait ? "wait" : "no wait") << ": " << (i_bAllEvents ? "all events" : "one event") << ": " << nReleased); + if ( i_bWait && Scheduler::HasPendingEvents() ) + i_bWait = false; + // TODO: there's a data race here on WNT only because ImplYield may be // called without SolarMutex; if we can get rid of LazyDelete (with VclPtr) // then the only remaining use of mnDispatchLevel is in OSX specific code commit e170965e389dfe7b87e70ae8c90a9c0715267a6e Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Sun Jul 31 17:31:07 2016 +0200 Just schedule tasks, if timeout has ellapsed As the native main loop wakes up on new events and not just by timer timeouts, make sure there is really an ellapsed event. Probably we should just schedule events via the system timeout. At least this will prevent expensive re-scheduling. Conflicts: vcl/source/app/scheduler.cxx Change-Id: I248c9b8acb7df026295d10f256871b9fc8d39c07 diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 1d7875e..11b5b56 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -313,13 +313,17 @@ struct ImplSVData Application* mpApp; // pApp VclPtr<WorkWindow> mpDefaultWin; // Default-Window bool mbDeInit; // Is VCL deinitializing + ImplSchedulerData* mpFirstSchedulerData; // list of all running tasks ImplSchedulerData* mpFreeSchedulerData; // list of all deleted tasks for reuse + bool mbNeedsReschedule; // indicator, if the list of tasks has changed + sal_uInt64 mnTimerPeriod; // current timer period / sleep time + sal_uInt64 mnLastUpdate; // last scheduler time SalTimer* mpSalTimer; // interface to sal event loop/timers + SalI18NImeStatus* mpImeStatus; // interface to ime status window SalSystem* mpSalSystem; // SalSystem interface ResMgr* mpResMgr; // SV-Resource-Manager - sal_uInt64 mnTimerPeriod; // current timer period ImplSVAppData maAppData; // indepen data for class Application ImplSVGDIData maGDIData; // indepen data for Output classes ImplSVWinData maWinData; // indepen data for Windows classes diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 7920440..7df76bc 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -130,6 +130,8 @@ void Scheduler::ImplStartTimer( sal_uInt64 nMS ) void Scheduler::CallbackTaskScheduling() { // this function is for the saltimer callback + ImplSVData* pSVData = ImplGetSVData(); + pSVData->mbNeedsReschedule = true; Scheduler::ProcessTaskScheduling(); } @@ -156,11 +158,15 @@ inline void Scheduler::UpdateMinPeriod( ImplSchedulerData *pSchedulerData, bool Scheduler::ProcessTaskScheduling() { ImplSVData* pSVData = ImplGetSVData(); + sal_uInt64 nTime = tools::Time::GetSystemTicks(); + if (!pSVData->mbNeedsReschedule && + (nTime < pSVData->mnLastUpdate + pSVData->mnTimerPeriod) ) + return false; + pSVData->mbNeedsReschedule = false; + ImplSchedulerData* pSchedulerData = pSVData->mpFirstSchedulerData; ImplSchedulerData* pPrevSchedulerData = nullptr; ImplSchedulerData *pMostUrgent = nullptr; - - sal_uInt64 nTime = tools::Time::GetSystemTicks(); sal_uInt64 nMinPeriod = InfiniteTimeoutMs; while ( pSchedulerData ) @@ -222,6 +228,7 @@ next_entry: pSVData->mpSalTimer->Stop(); pSVData->mnTimerPeriod = nMinPeriod; + pSVData->mnLastUpdate = nTime; return pMostUrgent != nullptr; } @@ -261,7 +268,10 @@ void Scheduler::Start() else pSVData->mpFirstSchedulerData = mpSchedulerData; } - mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks(); + + assert( mpSchedulerData->mpScheduler == this ); + mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks(); + pSVData->mbNeedsReschedule = true; } void Scheduler::Stop() commit 842769ce672b43f8d385a40d86559ff4ce9df8c5 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Mon Sep 12 17:03:29 2016 +0200 Drop special idle handling Idles are just instant, mainly low-priority timers. So we'll just schedule by priority. Change-Id: I446eaea0077f45a5b7daa0aa06dcb80010ac0bd5 diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 9e58327..6c6442e 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -375,7 +375,7 @@ void DesktopLOKTest::testSearchCalc() {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))}, })); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); std::vector<OString> aSelections; sal_Int32 nIndex = 0; @@ -409,7 +409,7 @@ void DesktopLOKTest::testSearchAllNotificationsCalc() {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))}, })); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // This was 1, make sure that we get no notifications about selection changes during search. CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult); @@ -679,7 +679,7 @@ void DesktopLOKTest::testCommandResult() // the condition var. m_aCommandResultCondition.reset(); pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", nullptr, true); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); m_aCommandResultCondition.wait(aTimeValue); CPPUNIT_ASSERT(m_aCommandResult.isEmpty()); @@ -689,7 +689,7 @@ void DesktopLOKTest::testCommandResult() m_aCommandResultCondition.reset(); pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", nullptr, true); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); m_aCommandResultCondition.wait(aTimeValue); boost::property_tree::ptree aTree; @@ -712,7 +712,7 @@ void DesktopLOKTest::testWriterComments() TimeValue aTimeValue = {2 , 0}; // 2 seconds max m_aCommandResultCondition.reset(); pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", nullptr, true); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); m_aCommandResultCondition.wait(aTimeValue); CPPUNIT_ASSERT(!m_aCommandResult.isEmpty()); xToolkit->reschedule(); @@ -753,10 +753,10 @@ void DesktopLOKTest::testModifiedStatus() m_bModified = false; m_aStateChangedCondition.reset(); pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max m_aStateChangedCondition.wait(aTimeValue); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // This was false, there was no callback about the modified status change. CPPUNIT_ASSERT(m_bModified); @@ -767,9 +767,9 @@ void DesktopLOKTest::testModifiedStatus() utl::TempFile aTempFile; aTempFile.EnableKillingFile(); CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "odt", "TakeOwnership")); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); m_aStateChangedCondition.wait(aTimeValue); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // There was no callback about the modified status change. CPPUNIT_ASSERT(!m_bModified); @@ -777,9 +777,9 @@ void DesktopLOKTest::testModifiedStatus() // Modify the document again m_aStateChangedCondition.reset(); pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); m_aStateChangedCondition.wait(aTimeValue); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // There was no callback about the modified status change. CPPUNIT_ASSERT(m_bModified); @@ -792,7 +792,7 @@ void DesktopLOKTest::testModifiedStatus() m_aStateChangedCondition.reset(); pDocument->pClass->postUnoCommand(pDocument, ".uno:Save", nullptr, false); m_aStateChangedCondition.wait(aTimeValue); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // There was no callback about the modified status change. CPPUNIT_ASSERT(!m_bModified); @@ -812,12 +812,12 @@ void DesktopLOKTest::testTrackChanges() pDocument->pClass->createView(pDocument); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // Enable trak changes and assert that both views get notified. m_nTrackChanges = 0; pDocument->pClass->postUnoCommand(pDocument, ".uno:TrackChanges", nullptr, false); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // This was 1, only the active view was notified. CPPUNIT_ASSERT_EQUAL(2, m_nTrackChanges); @@ -1049,7 +1049,7 @@ void DesktopLOKTest::testContextMenuCalc() LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aPointOnImage.X(), aPointOnImage.Y(), 1, 4, 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); TimeValue aTimeValue = {2 , 0}; // 2 seconds max m_aContextMenuCondition.wait(aTimeValue); @@ -1159,7 +1159,7 @@ void DesktopLOKTest::testContextMenuWriter() LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aRandomPoint.X(), aRandomPoint.Y(), 1, 4, 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); TimeValue aTimeValue = {2 , 0}; // 2 seconds max m_aContextMenuCondition.wait(aTimeValue); @@ -1215,7 +1215,7 @@ void DesktopLOKTest::testContextMenuImpress() LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aRandomPoint.X(), aRandomPoint.Y(), 1, 4, 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); TimeValue aTimeValue = {2 , 0}; // 2 seconds max m_aContextMenuCondition.wait(aTimeValue); @@ -1371,7 +1371,7 @@ void DesktopLOKTest::testNotificationCompression() handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // Should be dropped. handler->queue(LOK_CALLBACK_SET_PART, "1"); // Should be dropped. - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(13), notifs.size()); diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx index 1027f0c..f50e329 100644 --- a/include/vcl/idle.hxx +++ b/include/vcl/idle.hxx @@ -31,7 +31,7 @@ protected: virtual void SetDeletionFlags() override; - virtual bool ReadyForSchedule( const sal_uInt64 nTime, const bool bIdle ) const override; + virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const override; virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const override; public: diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx index aac4c63..47ce27c 100644 --- a/include/vcl/scheduler.hxx +++ b/include/vcl/scheduler.hxx @@ -58,7 +58,7 @@ protected: virtual void SetDeletionFlags(); - virtual bool ReadyForSchedule( const sal_uInt64 nTime, const bool bIdle ) const = 0; + virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const = 0; virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const = 0; public: @@ -84,11 +84,11 @@ public: static void ImplDeInitScheduler(); /// Process one pending Timer with highhest priority - static void CallbackTaskScheduling( bool bIdle ); + static void CallbackTaskScheduling(); /// Process one pending task ahead of time with highest priority. - static bool ProcessTaskScheduling( bool bIdle ); + static bool ProcessTaskScheduling(); /// Process all events until we are idle - static void ProcessEventsToIdle(); + static void ProcessAllPendingEvents(); /// Control the deterministic mode. In this mode, two subsequent runs of /// LibreOffice fire about the same amount idles. diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index e4c922e..4f7e3d8 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -32,7 +32,7 @@ protected: virtual void SetDeletionFlags() override; - virtual bool ReadyForSchedule( const sal_uInt64 nTime, const bool bIdle ) const override; + virtual bool ReadyForSchedule( const sal_uInt64 nTime ) const override; virtual void UpdateMinPeriod( const sal_uInt64 nTime, sal_uInt64 &nMinPeriod ) const override; public: diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 3ff46d0..ec159dd 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -442,7 +442,7 @@ void ScTiledRenderingTest::testViewCursors() CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated); pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN); pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); SfxLokHelper::destroyView(SfxLokHelper::getView()); CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated); mxComponent->dispose(); @@ -481,7 +481,7 @@ void ScTiledRenderingTest::testTextViewSelection() // Create a selection on two cells in the second view, that's a text selection in LOK terms. aView1.m_bTextViewSelectionInvalidated = false; lcl_dispatchCommand(mxComponent, ".uno:GoRightSel", {}); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // Make sure the first view got its notification. CPPUNIT_ASSERT(aView1.m_bTextViewSelectionInvalidated); @@ -504,7 +504,7 @@ void ScTiledRenderingTest::testDocumentSizeChanged() comphelper::makePropertyValue("ToPoint", OUString("$A$30")), }; lcl_dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // Assert that the size in the payload is not 0. CPPUNIT_ASSERT(m_aDocumentSize.getWidth() > 0); CPPUNIT_ASSERT(m_aDocumentSize.getHeight() > 0); diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index c25abc6..003fd44 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -93,7 +93,7 @@ sd::DrawDocShellRef SdMiscTest::Load(const OUString& rURL, sal_Int32 nFormat) for (int i = 0; i < 1000; i++) { // Process all Tasks - slide sorter is created here - while (Scheduler::ProcessTaskScheduling(true)); + while (Scheduler::ProcessTaskScheduling()); if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase())) != nullptr) break; osl::Thread::wait(std::chrono::milliseconds(100)); @@ -137,7 +137,7 @@ void SdMiscTest::testTdf96708() // Now wait for timers to trigger creation of auto-layout osl::Thread::wait(std::chrono::milliseconds(100)); - Scheduler::ProcessTaskScheduling(true); + Scheduler::ProcessTaskScheduling(); rSSController.GetClipboard().DoPaste(); const sal_uInt16 nMasterPageCnt2 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::PK_STANDARD); diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 28e0ac8..2cffca1 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -449,7 +449,7 @@ void SdTiledRenderingTest::testUndoShells() {"AttributePageSize.Height", uno::makeAny(static_cast<sal_Int32>(10000))}, })); comphelper::dispatchCommand(".uno:AttributePageSize", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // Assert that view shell ID tracking works for SdUndoAction subclasses. SdDrawDocument* pDocument = pXImpressDocument->GetDoc(); @@ -726,7 +726,7 @@ void SdTiledRenderingTest::testInsertTable() )); comphelper::dispatchCommand(".uno:InsertTable", aArgs); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // get the table sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -967,7 +967,7 @@ void SdTiledRenderingTest::testViewCursors() SdrObject* pObject = pActualPage->GetObj(0); SdrView* pView = pViewShell->GetView(); pView->MarkObj(pObject, pView->GetSdrPageView()); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // First view notices that there was a selection change in the other view. CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated); @@ -998,7 +998,7 @@ void SdTiledRenderingTest::testViewCursorParts() SdrObject* pObject = pActualPage->GetObj(0); SdrView* pView = pViewShell->GetView(); pView->MarkObj(pObject, pView->GetSdrPageView()); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // First view notices that there was a selection change in the other view. CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated); pView->UnmarkAllObj(pView->GetSdrPageView()); @@ -1010,7 +1010,7 @@ void SdTiledRenderingTest::testViewCursorParts() pActualPage = pViewShell->GetActualPage(); pObject = pActualPage->GetObj(0); pView->MarkObj(pObject, pView->GetSdrPageView()); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // First view ignores view selection, as it would be for part 1, and it's in part 0. // This failed when the "part" was always 0 in the callback. CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelectionInvalidated); @@ -1037,14 +1037,14 @@ void SdTiledRenderingTest::testCursorViews() pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT(pView->IsTextEdit()); // Make sure that cursor state is not changed just because we create a second view. aView1.m_bCursorVisibleChanged = false; SfxLokHelper::createView(); pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT(!aView1.m_bCursorVisibleChanged); // Make sure that typing in the first view causes an invalidation in the @@ -1056,7 +1056,7 @@ void SdTiledRenderingTest::testCursorViews() aView2.m_bTilesInvalidated = false; pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // This failed: the second view was not invalidated when pressing a key in // the first view. CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); @@ -1115,7 +1115,7 @@ void SdTiledRenderingTest::testUndoLimiting() pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT(pView->IsTextEdit()); // Now check what views see the undo action. @@ -1188,7 +1188,7 @@ void SdTiledRenderingTest::testCreateViewTextCursor() pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdrView* pSdrView = pViewShell->GetView(); CPPUNIT_ASSERT(pSdrView->IsTextEdit()); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index d5bcf1d..918a393 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -553,7 +553,7 @@ void SwTiledRenderingTest::testSearchAllNotifications() {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))}, })); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // This was 5, make sure that we get no notifications about selection changes during search. CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult); @@ -746,7 +746,7 @@ void SwTiledRenderingTest::testMissingInvalidation() aView2.m_bTilesInvalidated = false; pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DELETE); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DELETE); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); mxComponent->dispose(); @@ -860,7 +860,7 @@ void SwTiledRenderingTest::testViewCursorVisibility() Point aCenter = pObject->GetSnapRect().Center(); pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aCenter.getX(), aCenter.getY(), 1, MOUSE_LEFT, 0); pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aCenter.getX(), aCenter.getY(), 1, MOUSE_LEFT, 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // Make sure the "view/text" cursor of the first view gets a notification. CPPUNIT_ASSERT(!aView1.m_bViewCursorVisible); mxComponent->dispose(); @@ -890,13 +890,13 @@ void SwTiledRenderingTest::testViewCursorCleanup() aView1.m_bGraphicViewSelection = false; pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aCenter.getX(), aCenter.getY(), 1, MOUSE_LEFT, 0); pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aCenter.getX(), aCenter.getY(), 1, MOUSE_LEFT, 0); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // Make sure there is a graphic view selection on the first view. CPPUNIT_ASSERT(aView1.m_bGraphicViewSelection); // Now destroy the second view. SfxLokHelper::destroyView(nView2); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), SfxLokHelper::getViews()); // Make sure that the graphic view selection on the first view is cleaned up. CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelection); @@ -999,7 +999,7 @@ void SwTiledRenderingTest::testUndoInvalidations() aView1.m_bTilesInvalidated = false; aView2.m_bTilesInvalidated = false; comphelper::dispatchCommand(".uno:Undo", {}); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); // Undo was dispatched on the first view, this second view was not invalidated. CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); @@ -1121,7 +1121,7 @@ void SwTiledRenderingTest::testUndoRepairDispatch() sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); comphelper::dispatchCommand(".uno:Undo", {}); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); // But the same is allowed in repair mode. @@ -1132,7 +1132,7 @@ void SwTiledRenderingTest::testUndoRepairDispatch() {"Repair", uno::makeAny(true)} })); comphelper::dispatchCommand(".uno:Undo", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // This was 1: repair mode couldn't undo the action, either. CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount()); @@ -1246,7 +1246,7 @@ void SwTiledRenderingTest::testTrackChanges() {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(0))} })); comphelper::dispatchCommand(".uno:RejectTrackedChange", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); // Assert that the reject was performed. SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 8d0ed48..a77fd7f 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -2806,7 +2806,7 @@ void SwUiWriterTest::testTdf97601() CPPUNIT_ASSERT_EQUAL(true, bool(xModifiable->isModified())); calcLayout(); // This never returned. - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); } void SwUiWriterTest::testTdf75137() @@ -3860,7 +3860,7 @@ void SwUiWriterTest::testRedlineParam() {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(1))} })); lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); // This was 'middlezzz', the uno command rejected the redline under the diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 6acd3bb..6ced639 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -1951,7 +1951,7 @@ void SAL_CALL VCLXToolkit::processEventsToIdle() throw (css::uno::RuntimeException, std::exception) { SolarMutexGuard aSolarGuard; - Scheduler::ProcessEventsToIdle(); + Scheduler::ProcessAllPendingEvents(); } sal_Int64 SAL_CALL VCLXToolkit::getOpenGLBufferSwapCounter() diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 28d1c69..53e7869b 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -240,8 +240,7 @@ bool SvpSalInstance::CheckTimeout( bool bExecuteTimers ) ImplSVData* pSVData = ImplGetSVData(); if( pSVData->mpSalTimer ) { - bool idle = true; // TODO - pSVData->mpSalTimer->CallCallback( idle ); + pSVData->mpSalTimer->CallCallback(); } } } diff --git a/vcl/inc/saltimer.hxx b/vcl/inc/saltimer.hxx index a143fbe..8585ddd 100644 --- a/vcl/inc/saltimer.hxx +++ b/vcl/inc/saltimer.hxx @@ -49,10 +49,10 @@ public: m_pProc = pProc; } - void CallCallback( bool idle ) + void CallCallback() { if( m_pProc ) - m_pProc( idle ); + m_pProc(); } }; diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx index b7f803e..7228b2e 100644 --- a/vcl/inc/salwtype.hxx +++ b/vcl/inc/salwtype.hxx @@ -261,7 +261,7 @@ struct SalLongPressEvent long mnY; }; -typedef void (*SALTIMERPROC)( bool idle ); +typedef void (*SALTIMERPROC)(); #endif // INCLUDED_VCL_INC_SALWTYPE_HXX diff --git a/vcl/inc/unx/saldata.hxx b/vcl/inc/unx/saldata.hxx index a115298..cfd8b53 100644 --- a/vcl/inc/unx/saldata.hxx +++ b/vcl/inc/unx/saldata.hxx @@ -72,7 +72,7 @@ public: inline SalXLib* GetLib() const { return pXLib_; } - static void Timeout( bool idle ); + static void Timeout(); // X errors virtual void ErrorTrapPush() override; diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx index cd7969b..53be65c 100644 --- a/vcl/osx/salinst.cxx +++ b/vcl/osx/salinst.cxx @@ -656,8 +656,7 @@ bool AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon // [AquaSalTimer::pRunningTimer fire]; if (ImplGetSVData()->mpSalTimer != nullptr) { - bool idle = true; // TODO - ImplGetSVData()->mpSalTimer->CallCallback( idle ); + ImplGetSVData()->mpSalTimer->CallCallback(); } } } diff --git a/vcl/osx/salnstimer.mm b/vcl/osx/salnstimer.mm index 307f194..6f8fb17 100644 --- a/vcl/osx/salnstimer.mm +++ b/vcl/osx/salnstimer.mm @@ -35,8 +35,7 @@ ImplSVData* pSVData = ImplGetSVData(); if( pSVData->mpSalTimer ) { - bool idle = true; // TODO - pSVData->mpSalTimer->CallCallback( idle ); + pSVData->mpSalTimer->CallCallback(); // NSTimer does not end nextEventMatchingMask of NSApplication // so we need to wakeup a waiting Yield to inform it something happened diff --git a/vcl/osx/saltimer.cxx b/vcl/osx/saltimer.cxx index 5a242e8..5811247 100644 --- a/vcl/osx/saltimer.cxx +++ b/vcl/osx/saltimer.cxx @@ -100,8 +100,7 @@ void AquaSalTimer::handleStartTimerEvent( NSEvent* pEvent ) if( pSVData->mpSalTimer ) { // timer already elapsed since event posted - bool idle = true; // TODO - pSVData->mpSalTimer->CallCallback( idle ); + pSVData->mpSalTimer->CallCallback(); } } ImplSalStartTimer( sal_uLong( [pEvent data1] ) ); diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index 0afa234..be7605a 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -187,7 +187,7 @@ void LifecycleTest::testFocus() xWin->Show(); xChild->GrabFocus(); // process asynchronous ToTop - Scheduler::ProcessTaskScheduling( true ); + Scheduler::ProcessTaskScheduling(); // FIXME: really awful to test focus issues without showing windows. // CPPUNIT_ASSERT(xChild->HasFocus()); } diff --git a/vcl/qa/cppunit/timer.cxx b/vcl/qa/cppunit/timer.cxx index 756b9381..d662ba9 100644 --- a/vcl/qa/cppunit/timer.cxx +++ b/vcl/qa/cppunit/timer.cxx @@ -115,7 +115,7 @@ void TimerTest::testIdle() { bool bTriggered = false; IdleBool aTest( bTriggered ); - Scheduler::ProcessTaskScheduling( true ); + Scheduler::ProcessTaskScheduling(); CPPUNIT_ASSERT_MESSAGE("idle triggered", bTriggered); } diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index 6c05452..1fe9819 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -74,10 +74,10 @@ void Idle::Start() Scheduler::ImplStartTimer(nPeriod); } -bool Idle::ReadyForSchedule( const sal_uInt64 /* nTime */, const bool bIdle ) const +bool Idle::ReadyForSchedule( const sal_uInt64 /* nTime */ ) const { // always ready if not only looking for timers. - return bIdle; + return true; } void Idle::UpdateMinPeriod( const sal_uInt64 /* nTime */, sal_uInt64 &nMinPeriod ) const diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index a9ecf86..7920440 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -127,10 +127,10 @@ void Scheduler::ImplStartTimer( sal_uInt64 nMS ) } } -void Scheduler::CallbackTaskScheduling( bool bIdle ) +void Scheduler::CallbackTaskScheduling() { // this function is for the saltimer callback - Scheduler::ProcessTaskScheduling( bIdle ); + Scheduler::ProcessTaskScheduling(); } static bool g_bDeterministicMode = false; @@ -153,9 +153,8 @@ inline void Scheduler::UpdateMinPeriod( ImplSchedulerData *pSchedulerData, assert( nMinPeriod >= ImmediateTimeoutMs ); } -bool Scheduler::ProcessTaskScheduling( bool bIdle ) +bool Scheduler::ProcessTaskScheduling() { - // if bIdle is false, only handle timer ImplSVData* pSVData = ImplGetSVData(); ImplSchedulerData* pSchedulerData = pSVData->mpFirstSchedulerData; ImplSchedulerData* pPrevSchedulerData = nullptr; @@ -185,7 +184,7 @@ bool Scheduler::ProcessTaskScheduling( bool bIdle ) } assert( pSchedulerData->mpScheduler ); - if ( !pSchedulerData->mpScheduler->ReadyForSchedule( nTime, bIdle ) ) + if ( !pSchedulerData->mpScheduler->ReadyForSchedule( nTime ) ) goto evaluate_entry; // if the priority of the current task is higher (numerical value is lower) than diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index f962f75..c3917da 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -503,7 +503,7 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased if (nReleased == 0) // tdf#99383 don't run stuff from ReAcquireSolarMutex { // Process all Tasks - bProcessedEvent = Scheduler::ProcessTaskScheduling( i_bWait ) || bProcessedEvent; + bProcessedEvent = Scheduler::ProcessTaskScheduling() || bProcessedEvent; } // flush lazy deleted objects @@ -520,10 +520,10 @@ void Application::Reschedule( bool i_bAllEvents ) ImplYield(false, i_bAllEvents, 0); } -void Scheduler::ProcessEventsToIdle() +void Scheduler::ProcessAllPendingEvents() { int nSanity = 1000; - while( Scheduler::ProcessTaskScheduling( true ) || + while( Scheduler::ProcessTaskScheduling() || ImplYield(false, true, 0) ) { if (nSanity-- < 0) diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index 2893bf3..fb5d382 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -28,7 +28,7 @@ void Timer::SetDeletionFlags() Scheduler::SetDeletionFlags(); } -bool Timer::ReadyForSchedule( const sal_uInt64 nTime, bool /* bIdle */ ) const +bool Timer::ReadyForSchedule( const sal_uInt64 nTime ) const { return (mpSchedulerData->mnUpdateTime + mnTimeout) <= nTime; } diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index f5ecd71..9f61f98 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -571,11 +571,11 @@ void X11SalData::XError( Display *pDisplay, XErrorEvent *pEvent ) m_aXErrorHandlerStack.back().m_bWas = true; } -void X11SalData::Timeout( bool idle ) +void X11SalData::Timeout() { ImplSVData* pSVData = ImplGetSVData(); if( pSVData->mpSalTimer ) - pSVData->mpSalTimer->CallCallback( idle ); + pSVData->mpSalTimer->CallCallback(); } struct YieldEntry @@ -654,20 +654,8 @@ bool SalXLib::CheckTimeout( bool bExecuteTimers ) * timers are being dispatched. */ m_aTimeout += m_nTimeoutMS; - // Determine if the app is idle (for idle timers). If there's user input pending, - // if there's IO pending or if we're called inside a temporary yield (=blockIdleTimeout), - // then the app is not idle. - bool idle = true; - if( blockIdleTimeout || XPending( vcl_sal::getSalDisplay(GetGenericData())->GetDisplay())) - idle = false; - for ( int nFD = 0; idle && nFD < nFDs_; nFD++ ) - { - YieldEntry* pEntry = &(yieldTable[nFD]); - if ( pEntry->fd && pEntry->HasPendingEvent()) - idle = false; - } // notify - X11SalData::Timeout( idle ); + X11SalData::Timeout(); } } } diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx index eaea532..69857ae 100644 --- a/vcl/unx/gtk/gtkdata.cxx +++ b/vcl/unx/gtk/gtkdata.cxx @@ -744,9 +744,7 @@ extern "C" { ImplSVData* pSVData = ImplGetSVData(); if( pSVData->mpSalTimer ) { - // TODO: context_pending should be probably checked too, but it causes locking assertion failures - bool idle = !pSalData->BlockIdleTimeout() && /*!g_main_context_pending( NULL ) &&*/ !gdk_events_pending(); - pSVData->mpSalTimer->CallCallback( idle ); + pSVData->mpSalTimer->CallCallback(); } return TRUE; diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx index 7591419..90f6be7 100644 --- a/vcl/unx/gtk3/gtk3gtkdata.cxx +++ b/vcl/unx/gtk3/gtk3gtkdata.cxx @@ -706,9 +706,7 @@ extern "C" { ImplSVData* pSVData = ImplGetSVData(); if( pSVData->mpSalTimer ) { - // TODO: context_pending should be probably checked too, but it causes locking assertion failures - bool idle = !pSalData->BlockIdleTimeout() && /*!g_main_context_pending( NULL ) &&*/ !gdk_events_pending(); - pSVData->mpSalTimer->CallCallback( idle ); + pSVData->mpSalTimer->CallCallback(); } return TRUE; diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx index b056221..1f64fa6 100644 --- a/vcl/unx/kde4/KDEXLib.cxx +++ b/vcl/unx/kde4/KDEXLib.cxx @@ -356,11 +356,7 @@ void KDEXLib::timeoutActivated() // some sense (timeouts should be more ok to wait and be triggered somewhen). while( SalKDEDisplay::self()->HasUserEvents() ) SalKDEDisplay::self()->DispatchInternalEvent(); - - // QGuiEventDispatcherGlib makes glib watch also X11 fd, but its hasPendingEvents() - // doesn't check X11, so explicitly check XPending() here. - bool idle = QApplication::hasPendingEvents() && !blockIdleTimeout && !XPending( QX11Info::display()); - X11SalData::Timeout( idle ); + X11SalData::Timeout(); // QTimer is not single shot, so will be restarted immediately } diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx index ff230c2..4ebb594 100644 --- a/vcl/win/app/saltimer.cxx +++ b/vcl/win/app/saltimer.cxx @@ -169,8 +169,7 @@ void EmitTimerCallback() // try this a short time later again. if (pSVData->mpSalTimer && ImplSalYieldMutexTryToAcquire()) { - bool idle = true; // TODO - pSVData->mpSalTimer->CallCallback( idle ); + pSVData->mpSalTimer->CallCallback(); ImplSalYieldMutexRelease(); // Run the timer again if it was started before, and also _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits