summaryrefslogtreecommitdiffstats
path: root/common/genericresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-19 19:53:24 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-19 19:53:24 +0200
commit820f9633f15aa20a03a44348012e98d6bd5e6bd9 (patch)
tree0d0fddc0fcb60a47366ac712bc64a3d4d5589ebc /common/genericresource.cpp
parent470f54718c9603b3f1ee5647e7d016f4f10a4059 (diff)
downloadsink-820f9633f15aa20a03a44348012e98d6bd5e6bd9.tar.gz
sink-820f9633f15aa20a03a44348012e98d6bd5e6bd9.zip
Got transactions to work.
With an ugly hack, we'll need to solve this in the messagequeue properly.
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r--common/genericresource.cpp19
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
206static void waitForDrained(KAsync::Future<void> &f, MessageQueue &queue) 207static 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);