[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - desktop/inc desktop/source
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 28 12:02:04 UTC 2021
desktop/inc/lib/init.hxx | 9 +++++++++
desktop/source/lib/init.cxx | 26 ++++++++++++++++++++++----
2 files changed, 31 insertions(+), 4 deletions(-)
New commits:
commit 3f6f1a45c1f4225817188f97721e6546e38871e2
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Sep 24 00:11:04 2021 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Sep 28 14:01:25 2021 +0200
add extra timeout with higher priority to LOK flushing
The normal idle has TaskPriority::POST_PAINT, which means that
if we get too busy, the idle won't be called for a long time,
meaning the queue will get longer and longer, making its processing
slower, and client interactivity will be very poor, with updates
possibly coming only when everything becomes idle.
The second timeout will flush the queue after a reasonable timeout.
I don't think there's an optimal value, so let's choose 100ms for now.
Change-Id: Ia1312a690aefd2c8628c82e0f42b2993802d8b1e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122737
Tested-by: Luboš Luňák <l.lunak at collabora.com>
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 6cbabd3ccccb..eee6b0fb4d76 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -146,6 +146,15 @@ namespace desktop {
void *m_pData;
int m_nDisableCallbacks;
std::mutex m_mutex;
+ class TimeoutIdle : public Timer
+ {
+ public:
+ TimeoutIdle( CallbackFlushHandler* handler );
+ virtual void Invoke() override;
+ private:
+ CallbackFlushHandler* mHandler;
+ };
+ TimeoutIdle m_TimeoutIdle;
};
struct DESKTOP_DLLPUBLIC LibLODocument_Impl : public _LibreOfficeKitDocument
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 824f45b5d23f..3e09f2d8b5ab 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1392,12 +1392,28 @@ static OUString getGenerator()
extern "C" {
+CallbackFlushHandler::TimeoutIdle::TimeoutIdle( CallbackFlushHandler* handler )
+ : Timer( "lokit timer callback" )
+ , mHandler( handler )
+{
+ // A second timer with higher priority, it'll ensure we flush in reasonable time if we get too busy
+ // to get POST_PAINT priority processing. Otherwise it could take a long time to flush.
+ SetPriority(TaskPriority::DEFAULT);
+ SetTimeout( 100 ); // 100 ms
+}
+
+void CallbackFlushHandler::TimeoutIdle::Invoke()
+{
+ mHandler->Invoke();
+}
+
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData)
- : Idle( "lokit timer callback" ),
+ : Idle( "lokit idle callback" ),
m_pDocument(pDocument),
m_pCallback(pCallback),
m_pData(pData),
- m_nDisableCallbacks(0)
+ m_nDisableCallbacks(0),
+ m_TimeoutIdle( this )
{
SetPriority(TaskPriority::POST_PAINT);
@@ -1414,8 +1430,6 @@ CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li
m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE, "NIL");
m_states.emplace(LOK_CALLBACK_SET_PART, "NIL");
m_states.emplace(LOK_CALLBACK_TABLE_SELECTED, "NIL");
-
- Start();
}
CallbackFlushHandler::~CallbackFlushHandler()
@@ -1696,6 +1710,8 @@ void CallbackFlushHandler::queue(const int type, const char* data)
{
Start();
}
+ if (!m_TimeoutIdle.IsActive())
+ m_TimeoutIdle.Start();
}
bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& aCallbackData)
@@ -2059,6 +2075,8 @@ void CallbackFlushHandler::Invoke()
m_queue1.clear();
m_queue2.clear();
+ Stop();
+ m_TimeoutIdle.Stop();
}
bool CallbackFlushHandler::removeAll(int type)
More information about the Libreoffice-commits
mailing list