diff options
-rw-r--r-- | include/vcl/scheduler.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentTimerManager.cxx | 25 | ||||
-rw-r--r-- | vcl/source/app/scheduler.cxx | 5 |
3 files changed, 30 insertions, 12 deletions
diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx index ac429ed33b09..6233d134a8ed 100644 --- a/include/vcl/scheduler.hxx +++ b/include/vcl/scheduler.hxx @@ -65,6 +65,18 @@ public: */ static void ProcessEventsToIdle(); + /** + * Wakes up the scheduler + * + * This doesn't handle any events! It just ensures the Scheduler is run as + * soon as possible by forcing the Scheduler timer to fire. + * + * Can be used for complex UpdateMinPeriod function, where the task is + * actually active but not ready and we want to skip the Task::Start() + * queue append for faster reaction. + */ + static void Wakeup(); + /// Control the deterministic mode. In this mode, two subsequent runs of /// LibreOffice fire about the same amount idles. static void SetDeterministicMode(bool bDeterministic); diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx index 81c46b125840..7bd2e505a3a4 100644 --- a/sw/source/core/doc/DocumentTimerManager.cxx +++ b/sw/source/core/doc/DocumentTimerManager.cxx @@ -33,6 +33,7 @@ #include <docsh.hxx> #include <docfld.hxx> #include <fldbas.hxx> +#include <vcl/scheduler.hxx> namespace sw { @@ -49,10 +50,14 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc void DocumentTimerManager::StartIdling() { - if (m_nIdleBlockCount > 0) - m_bStartOnUnblock = true; - else if (!m_aDocIdle.IsActive()) - m_aDocIdle.Start(); + m_bStartOnUnblock = true; + if (0 == m_nIdleBlockCount) + { + if (!m_aDocIdle.IsActive()) + m_aDocIdle.Start(); + else + Scheduler::Wakeup(); + } } void DocumentTimerManager::StopIdling() @@ -64,11 +69,6 @@ void DocumentTimerManager::StopIdling() void DocumentTimerManager::BlockIdling() { assert(SAL_MAX_UINT32 != m_nIdleBlockCount); - if (0 == m_nIdleBlockCount) - { - assert(!m_bStartOnUnblock); - m_bStartOnUnblock = false; - } ++m_nIdleBlockCount; } @@ -79,10 +79,10 @@ void DocumentTimerManager::UnblockIdling() if ((0 == m_nIdleBlockCount) && m_bStartOnUnblock) { - m_bStartOnUnblock = false; - // kick the active idle, if it's not anymore blocked by IsDocIdle() - if (IsDocIdle()) + if (!m_aDocIdle.IsActive()) m_aDocIdle.Start(); + else + Scheduler::Wakeup(); } } @@ -137,6 +137,7 @@ IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, void ) pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" ); #endif BlockIdling(); + StopIdling(); IdleJob eJob = GetNextIdleJob(); diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 4a35115f2db3..93fcfeca7df9 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -506,6 +506,11 @@ next_entry: return !!pMostUrgent; } +void Scheduler::Wakeup() +{ + Scheduler::ImplStartTimer( 0, false, tools::Time::GetSystemTicks() ); +} + void Task::StartTimer( sal_uInt64 nMS ) { Scheduler::ImplStartTimer( nMS, false, tools::Time::GetSystemTicks() ); |