From 3506c78afcfcf63d74d1b57b53518ea27dae2f8c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 7 Mar 2017 14:56:03 +0100 Subject: Merge synchronization requests for individual mails of the same folder. We use this frequently when loading conversations, so this results in a significant preformance improvement. --- common/synchronizer.cpp | 14 ++++++++++---- common/synchronizer.h | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index b147615..fcdb5b8 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -252,15 +252,21 @@ void Synchronizer::modify(const DomainType &entity, const QByteArray &newResourc QList Synchronizer::getSyncRequests(const Sink::QueryBase &query) { - QList list; - list << Synchronizer::SyncRequest{query, "sync"}; - return list; + return QList() << Synchronizer::SyncRequest{query, "sync"}; +} + +void Synchronizer::mergeIntoQueue(const Synchronizer::SyncRequest &request, QList &queue) +{ + mSyncRequestQueue << request; } void Synchronizer::synchronize(const Sink::QueryBase &query) { SinkTraceCtx(mLogCtx) << "Synchronizing"; - mSyncRequestQueue << getSyncRequests(query); + auto newRequests = getSyncRequests(query); + for (const auto &request: newRequests) { + mergeIntoQueue(request, mSyncRequestQueue); + } processSyncQueue().exec(); } diff --git a/common/synchronizer.h b/common/synchronizer.h index 120a8a5..af042cb 100644 --- a/common/synchronizer.h +++ b/common/synchronizer.h @@ -175,6 +175,11 @@ protected: */ virtual QList getSyncRequests(const Sink::QueryBase &query); + /** + * This allows the synchronizer to merge new requests with existing requests in the queue. + */ + virtual void mergeIntoQueue(const Synchronizer::SyncRequest &request, QList &queue); + protected: Sink::Log::Context mLogCtx; private: -- cgit v1.2.3