diff options
-rw-r--r-- | common/genericresource.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 943f7d2..e2b0122 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -195,12 +195,13 @@ void GenericResource::processCommand(int commandId, const QByteArray &data) | |||
195 | mUserQueue.startTransaction(); | 195 | mUserQueue.startTransaction(); |
196 | enqueueCommand(mUserQueue, commandId, data); | 196 | enqueueCommand(mUserQueue, commandId, data); |
197 | modifications++; | 197 | modifications++; |
198 | // if (modifications >= 100) { | 198 | if (modifications >= 100) { |
199 | mUserQueue.commit(); | 199 | mUserQueue.commit(); |
200 | // modifications = 0; | 200 | modifications = 0; |
201 | // } else { | 201 | mCommitQueueTimer.stop(); |
202 | // mCommitQueueTimer.start(); | 202 | } else { |
203 | // } | 203 | mCommitQueueTimer.start(); |
204 | } | ||
204 | } | 205 | } |
205 | 206 | ||
206 | static void waitForDrained(KAsync::Future<void> &f, MessageQueue &queue) | 207 | static void waitForDrained(KAsync::Future<void> &f, MessageQueue &queue) |
@@ -220,6 +221,14 @@ KAsync::Job<void> GenericResource::processAllMessages() | |||
220 | //TODO: report errors while processing sync? | 221 | //TODO: report errors while processing sync? |
221 | //TODO JOBAPI: A helper that waits for n events and then continues? | 222 | //TODO JOBAPI: A helper that waits for n events and then continues? |
222 | return KAsync::start<void>([this](KAsync::Future<void> &f) { | 223 | return KAsync::start<void>([this](KAsync::Future<void> &f) { |
224 | if (mCommitQueueTimer.isActive()) { | ||
225 | QObject::connect(&mCommitQueueTimer, &QTimer::timeout, [&f]() { | ||
226 | f.setFinished(); | ||
227 | }); | ||
228 | } else { | ||
229 | f.setFinished(); | ||
230 | } | ||
231 | }).then<void>([this](KAsync::Future<void> &f) { | ||
223 | waitForDrained(f, mSynchronizerQueue); | 232 | waitForDrained(f, mSynchronizerQueue); |
224 | }).then<void>([this](KAsync::Future<void> &f) { | 233 | }).then<void>([this](KAsync::Future<void> &f) { |
225 | waitForDrained(f, mUserQueue); | 234 | waitForDrained(f, mUserQueue); |