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