summaryrefslogtreecommitdiffstats
path: root/common/genericresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-28 13:51:58 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-28 13:51:58 +0100
commitd2654f78a4f7e87b44e296477e4d90646c967670 (patch)
treeae84d766482840fcff14901ff012aa47365fb38c /common/genericresource.cpp
parentec9c7acd87538942aa58bc93728ea2991eb9aac8 (diff)
downloadsink-d2654f78a4f7e87b44e296477e4d90646c967670.tar.gz
sink-d2654f78a4f7e87b44e296477e4d90646c967670.zip
Only hardcode once if we have to
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r--common/genericresource.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp
index afe3900..a6213d7 100644
--- a/common/genericresource.cpp
+++ b/common/genericresource.cpp
@@ -10,6 +10,8 @@
10#include "log.h" 10#include "log.h"
11#include "definitions.h" 11#include "definitions.h"
12 12
13static int sBatchSize = 100;
14
13using namespace Akonadi2; 15using namespace Akonadi2;
14 16
15/** 17/**
@@ -206,8 +208,7 @@ private slots:
206 }).then(KAsync::dowhile( 208 }).then(KAsync::dowhile(
207 [queue]() { return !queue->isEmpty(); }, 209 [queue]() { return !queue->isEmpty(); },
208 [this, queue](KAsync::Future<void> &future) { 210 [this, queue](KAsync::Future<void> &future) {
209 const int batchSize = 100; 211 queue->dequeueBatch(sBatchSize, [this](const QByteArray &data) {
210 queue->dequeueBatch(batchSize, [this](const QByteArray &data) {
211 return KAsync::start<void>([this, data](KAsync::Future<void> &future) { 212 return KAsync::start<void>([this, data](KAsync::Future<void> &future) {
212 processQueuedCommand(data).then<void, qint64>([&future, this](qint64 createdRevision) { 213 processQueuedCommand(data).then<void, qint64>([&future, this](qint64 createdRevision) {
213 Trace() << "Created revision " << createdRevision; 214 Trace() << "Created revision " << createdRevision;
@@ -357,11 +358,10 @@ void GenericResource::enqueueCommand(MessageQueue &mq, int commandId, const QByt
357void GenericResource::processCommand(int commandId, const QByteArray &data) 358void GenericResource::processCommand(int commandId, const QByteArray &data)
358{ 359{
359 static int modifications = 0; 360 static int modifications = 0;
360 const int batchSize = 100;
361 mUserQueue.startTransaction(); 361 mUserQueue.startTransaction();
362 enqueueCommand(mUserQueue, commandId, data); 362 enqueueCommand(mUserQueue, commandId, data);
363 modifications++; 363 modifications++;
364 if (modifications >= batchSize) { 364 if (modifications >= sBatchSize) {
365 mUserQueue.commit(); 365 mUserQueue.commit();
366 modifications = 0; 366 modifications = 0;
367 mCommitQueueTimer.stop(); 367 mCommitQueueTimer.stop();