Kaydet (Commit) 3bd83167 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

tdf#119458 just wakeup Scheduler on active Idle

So this almost returns the code to the original state, before I
started fixing tdf#116370... a long way. This introduces the new
Scheduler::Wakeup() function, which will just queue a Scheduler
event in the System event queue unconditionally.

This should prevent fdo#73165, which I couldn't reproduce, but
just to be sure.

More importantly this patch resets the m_bStartOnUnblock when
the Idle job actually runs. This run should already determinates
if more Idle work needs to be done, and others can still call
BeginIdling() to ensure further processing.

This also drops the IsBusyDoc() test from UnblockIdling(). We
can't really know, if the document is still busy when the
Scheduler is finally running, be it by the system timer or
Application::Reschedule().

Change-Id: I6cc4a3c48dcaf62b6985c7bc1c95c96697443f3b
Reviewed-on: https://gerrit.libreoffice.org/59730
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst b406744b
...@@ -65,6 +65,18 @@ public: ...@@ -65,6 +65,18 @@ public:
*/ */
static void ProcessEventsToIdle(); 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 /// Control the deterministic mode. In this mode, two subsequent runs of
/// LibreOffice fire about the same amount idles. /// LibreOffice fire about the same amount idles.
static void SetDeterministicMode(bool bDeterministic); static void SetDeterministicMode(bool bDeterministic);
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <docsh.hxx> #include <docsh.hxx>
#include <docfld.hxx> #include <docfld.hxx>
#include <fldbas.hxx> #include <fldbas.hxx>
#include <vcl/scheduler.hxx>
namespace sw namespace sw
{ {
...@@ -49,10 +50,14 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ...@@ -49,10 +50,14 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc
void DocumentTimerManager::StartIdling() void DocumentTimerManager::StartIdling()
{ {
if (m_nIdleBlockCount > 0) m_bStartOnUnblock = true;
m_bStartOnUnblock = true; if (0 == m_nIdleBlockCount)
else if (!m_aDocIdle.IsActive()) {
m_aDocIdle.Start(); if (!m_aDocIdle.IsActive())
m_aDocIdle.Start();
else
Scheduler::Wakeup();
}
} }
void DocumentTimerManager::StopIdling() void DocumentTimerManager::StopIdling()
...@@ -64,11 +69,6 @@ void DocumentTimerManager::StopIdling() ...@@ -64,11 +69,6 @@ void DocumentTimerManager::StopIdling()
void DocumentTimerManager::BlockIdling() void DocumentTimerManager::BlockIdling()
{ {
assert(SAL_MAX_UINT32 != m_nIdleBlockCount); assert(SAL_MAX_UINT32 != m_nIdleBlockCount);
if (0 == m_nIdleBlockCount)
{
assert(!m_bStartOnUnblock);
m_bStartOnUnblock = false;
}
++m_nIdleBlockCount; ++m_nIdleBlockCount;
} }
...@@ -79,10 +79,10 @@ void DocumentTimerManager::UnblockIdling() ...@@ -79,10 +79,10 @@ void DocumentTimerManager::UnblockIdling()
if ((0 == m_nIdleBlockCount) && m_bStartOnUnblock) if ((0 == m_nIdleBlockCount) && m_bStartOnUnblock)
{ {
m_bStartOnUnblock = false; if (!m_aDocIdle.IsActive())
// kick the active idle, if it's not anymore blocked by IsDocIdle()
if (IsDocIdle())
m_aDocIdle.Start(); m_aDocIdle.Start();
else
Scheduler::Wakeup();
} }
} }
...@@ -137,6 +137,7 @@ IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, void ) ...@@ -137,6 +137,7 @@ IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, void )
pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" ); pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" );
#endif #endif
BlockIdling(); BlockIdling();
StopIdling();
IdleJob eJob = GetNextIdleJob(); IdleJob eJob = GetNextIdleJob();
......
...@@ -506,6 +506,11 @@ next_entry: ...@@ -506,6 +506,11 @@ next_entry:
return !!pMostUrgent; return !!pMostUrgent;
} }
void Scheduler::Wakeup()
{
Scheduler::ImplStartTimer( 0, false, tools::Time::GetSystemTicks() );
}
void Task::StartTimer( sal_uInt64 nMS ) void Task::StartTimer( sal_uInt64 nMS )
{ {
Scheduler::ImplStartTimer( nMS, false, tools::Time::GetSystemTicks() ); Scheduler::ImplStartTimer( nMS, false, tools::Time::GetSystemTicks() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment