Kaydet (Commit) 799a590a authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

Don't poll busy documents via idle task

Creates a very busy idle-loop, for non-task work like mail merge.

Change-Id: If7be82e4675008f23e6f4f6be5c40df40a231a8b
üst 36f93104
......@@ -40,44 +40,44 @@ namespace sw
DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
mbStartIdleTimer( false ),
mIdleBlockCount( 0 ),
maIdle("DocumentTimerManagerIdleTimer")
maDocIdle( i_rSwdoc )
{
maIdle.SetPriority( TaskPriority::LOWEST );
maIdle.SetInvokeHandler( LINK( this, DocumentTimerManager, DoIdleJobs) );
maIdle.SetDebugName( "sw::DocumentTimerManager maIdle" );
maDocIdle.SetPriority( TaskPriority::LOWEST );
maDocIdle.SetInvokeHandler( LINK( this, DocumentTimerManager, DoIdleJobs) );
maDocIdle.SetDebugName( "sw::DocumentTimerManager maDocIdle" );
}
void DocumentTimerManager::StartIdling()
{
mbStartIdleTimer = true;
if( !mIdleBlockCount )
maIdle.Start();
maDocIdle.Start();
}
void DocumentTimerManager::StopIdling()
{
mbStartIdleTimer = false;
maIdle.Stop();
maDocIdle.Stop();
}
void DocumentTimerManager::BlockIdling()
{
maIdle.Stop();
maDocIdle.Stop();
++mIdleBlockCount;
}
void DocumentTimerManager::UnblockIdling()
{
--mIdleBlockCount;
if( !mIdleBlockCount && mbStartIdleTimer && !maIdle.IsActive() )
maIdle.Start();
if( !mIdleBlockCount && mbStartIdleTimer && !maDocIdle.IsActive() )
maDocIdle.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 (!maDocIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0
maDocIdle.Start();
}
IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
......@@ -96,10 +96,7 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
for(SwViewShell& rSh : pShell->GetRingContainer())
{
if( rSh.ActionPend() )
{
pIdle->Start();
return;
}
}
if( pTmpRoot->IsNeedGrammarCheck() )
......@@ -119,9 +116,7 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
if ((*pLayIter)->IsIdleFormat())
{
(*pLayIter)->GetCurrShell()->LayoutIdle();
// Defer the remaining work.
pIdle->Start();
return;
}
}
......@@ -135,11 +130,8 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
/* && !pStartSh->GetViewOptions()->IsFieldName()*/ )
{
if ( m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().IsInUpdateFields() ||
m_rDoc.getIDocumentFieldsAccess().IsExpFieldsLocked() )
{
pIdle->Start();
m_rDoc.getIDocumentFieldsAccess().IsExpFieldsLocked() )
return;
}
// Action brackets!
m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().SetInUpdateFields( true );
......@@ -167,6 +159,7 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
if( pModLogFile && 1 != (long)pModLogFile )
delete pModLogFile, static_cast<long&>(pModLogFile) = 1;
#endif
pIdle->Stop();
}
DocumentTimerManager::~DocumentTimerManager() {}
......
......@@ -21,8 +21,8 @@
#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX
#include <IDocumentTimerAccess.hxx>
#include <SwDocIdle.hxx>
#include <vcl/idle.hxx>
#include <sal/types.h>
#include <tools/link.hxx>
......@@ -47,7 +47,6 @@ public:
void StartBackgroundJobs() override;
// Our own 'IdleTimer' calls the following method
DECL_LINK( DoIdleJobs, Timer *, void );
virtual ~DocumentTimerManager() override;
......@@ -61,7 +60,7 @@ private:
bool mbStartIdleTimer; //< idle timer mode start/stop
sal_Int32 mIdleBlockCount;
Idle maIdle;
SwDocIdle maDocIdle;
};
}
......
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