diff options
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r-- | common/genericresource.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index ea6413b..2394b80 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -61,33 +61,33 @@ private slots: | |||
61 | }).exec(); | 61 | }).exec(); |
62 | } | 62 | } |
63 | 63 | ||
64 | Async::Job<void> processQueuedCommand(const Akonadi2::QueuedCommand *queuedCommand) | 64 | KAsync::Job<void> processQueuedCommand(const Akonadi2::QueuedCommand *queuedCommand) |
65 | { | 65 | { |
66 | Log() << "Processing command: " << Akonadi2::Commands::name(queuedCommand->commandId()); | 66 | Log() << "Processing command: " << Akonadi2::Commands::name(queuedCommand->commandId()); |
67 | //Throw command into appropriate pipeline | 67 | //Throw command into appropriate pipeline |
68 | switch (queuedCommand->commandId()) { | 68 | switch (queuedCommand->commandId()) { |
69 | case Akonadi2::Commands::DeleteEntityCommand: | 69 | case Akonadi2::Commands::DeleteEntityCommand: |
70 | //mPipeline->removedEntity | 70 | //mPipeline->removedEntity |
71 | return Async::null<void>(); | 71 | return KAsync::null<void>(); |
72 | case Akonadi2::Commands::ModifyEntityCommand: | 72 | case Akonadi2::Commands::ModifyEntityCommand: |
73 | //mPipeline->modifiedEntity | 73 | //mPipeline->modifiedEntity |
74 | return Async::null<void>(); | 74 | return KAsync::null<void>(); |
75 | case Akonadi2::Commands::CreateEntityCommand: | 75 | case Akonadi2::Commands::CreateEntityCommand: |
76 | return mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); | 76 | return mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); |
77 | default: | 77 | default: |
78 | return Async::error<void>(-1, "Unhandled command"); | 78 | return KAsync::error<void>(-1, "Unhandled command"); |
79 | } | 79 | } |
80 | return Async::null<void>(); | 80 | return KAsync::null<void>(); |
81 | } | 81 | } |
82 | 82 | ||
83 | //Process all messages of this queue | 83 | //Process all messages of this queue |
84 | Async::Job<void> processQueue(MessageQueue *queue) | 84 | KAsync::Job<void> processQueue(MessageQueue *queue) |
85 | { | 85 | { |
86 | //TODO use something like: | 86 | //TODO use something like: |
87 | //Async::foreach("pass iterator here").each("process value here").join(); | 87 | //KAsync::foreach("pass iterator here").each("process value here").join(); |
88 | //Async::foreach("pass iterator here").parallel("process value here").join(); | 88 | //KAsync::foreach("pass iterator here").parallel("process value here").join(); |
89 | return Async::dowhile( | 89 | return KAsync::dowhile( |
90 | [this, queue](Async::Future<bool> &future) { | 90 | [this, queue](KAsync::Future<bool> &future) { |
91 | if (queue->isEmpty()) { | 91 | if (queue->isEmpty()) { |
92 | future.setValue(false); | 92 | future.setValue(false); |
93 | future.setFinished(); | 93 | future.setFinished(); |
@@ -133,13 +133,13 @@ private slots: | |||
133 | ); | 133 | ); |
134 | } | 134 | } |
135 | 135 | ||
136 | Async::Job<void> processPipeline() | 136 | KAsync::Job<void> processPipeline() |
137 | { | 137 | { |
138 | //Go through all message queues | 138 | //Go through all message queues |
139 | auto it = QSharedPointer<QListIterator<MessageQueue*> >::create(mCommandQueues); | 139 | auto it = QSharedPointer<QListIterator<MessageQueue*> >::create(mCommandQueues); |
140 | return Async::dowhile( | 140 | return KAsync::dowhile( |
141 | [it]() { return it->hasNext(); }, | 141 | [it]() { return it->hasNext(); }, |
142 | [it, this](Async::Future<void> &future) { | 142 | [it, this](KAsync::Future<void> &future) { |
143 | auto queue = it->next(); | 143 | auto queue = it->next(); |
144 | processQueue(queue).then<void>([&future]() { | 144 | processQueue(queue).then<void>([&future]() { |
145 | Trace() << "Queue processed"; | 145 | Trace() << "Queue processed"; |
@@ -206,12 +206,12 @@ void GenericResource::processCommand(int commandId, const QByteArray &data, uint | |||
206 | enqueueCommand(mUserQueue, commandId, data); | 206 | enqueueCommand(mUserQueue, commandId, data); |
207 | } | 207 | } |
208 | 208 | ||
209 | Async::Job<void> GenericResource::processAllMessages() | 209 | KAsync::Job<void> GenericResource::processAllMessages() |
210 | { | 210 | { |
211 | //We have to wait for all items to be processed to ensure the synced items are available when a query gets executed. | 211 | //We have to wait for all items to be processed to ensure the synced items are available when a query gets executed. |
212 | //TODO: report errors while processing sync? | 212 | //TODO: report errors while processing sync? |
213 | //TODO JOBAPI: A helper that waits for n events and then continues? | 213 | //TODO JOBAPI: A helper that waits for n events and then continues? |
214 | return Async::start<void>([this](Async::Future<void> &f) { | 214 | return KAsync::start<void>([this](KAsync::Future<void> &f) { |
215 | if (mSynchronizerQueue.isEmpty()) { | 215 | if (mSynchronizerQueue.isEmpty()) { |
216 | f.setFinished(); | 216 | f.setFinished(); |
217 | } else { | 217 | } else { |
@@ -219,7 +219,7 @@ Async::Job<void> GenericResource::processAllMessages() | |||
219 | f.setFinished(); | 219 | f.setFinished(); |
220 | }); | 220 | }); |
221 | } | 221 | } |
222 | }).then<void>([this](Async::Future<void> &f) { | 222 | }).then<void>([this](KAsync::Future<void> &f) { |
223 | if (mUserQueue.isEmpty()) { | 223 | if (mUserQueue.isEmpty()) { |
224 | f.setFinished(); | 224 | f.setFinished(); |
225 | } else { | 225 | } else { |