summaryrefslogtreecommitdiffstats
path: root/common/genericresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-16 12:45:17 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-18 18:48:06 +0200
commit726a49431909dbd8bdc6efdb8a36ddf4214a7328 (patch)
tree48103c645dac6aaa0f4eba6cea89ab347333329d /common/genericresource.cpp
parentc7f813895866981ef97c99ed52d2d2a80dc13178 (diff)
downloadsink-726a49431909dbd8bdc6efdb8a36ddf4214a7328.tar.gz
sink-726a49431909dbd8bdc6efdb8a36ddf4214a7328.zip
Batch dequeue in messagequeue.
The messagequeue removes all dequeued values once all values have been processed in a single transaction.
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r--common/genericresource.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp
index b3df389..bbd992b 100644
--- a/common/genericresource.cpp
+++ b/common/genericresource.cpp
@@ -106,19 +106,9 @@ private slots:
106 //KAsync::foreach("pass iterator here").parallel("process value here").join(); 106 //KAsync::foreach("pass iterator here").parallel("process value here").join();
107 return KAsync::dowhile( 107 return KAsync::dowhile(
108 [this, queue](KAsync::Future<bool> &future) { 108 [this, queue](KAsync::Future<bool> &future) {
109 queue->dequeueBatch(100, [this](void *ptr, int size, std::function<void(bool success)> messageQueueCallback) { 109 queue->dequeueBatch(100, [this](const QByteArray &data) {
110 Trace() << "Got value"; 110 Trace() << "Got value";
111 processQueuedCommand(QByteArray::fromRawData(static_cast<char*>(ptr), size)).then<void>( 111 return processQueuedCommand(data);
112 [&messageQueueCallback]() {
113 Trace() << "done";
114 messageQueueCallback(true);
115 },
116 [&messageQueueCallback](int errorCode, QString errorMessage) {
117 //Use false?
118 //For now we use true to make sure we don't get stuck on messages we fail to process
119 messageQueueCallback(true);
120 }
121 ).exec();
122 } 112 }
123 ).then<void>([&future](){ 113 ).then<void>([&future](){
124 future.setValue(true); 114 future.setValue(true);