diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-01 01:40:23 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-01 01:40:23 +0200 |
commit | 65131b9470455ae52a86d811882ca1d97c4a899c (patch) | |
tree | 6dd46350a18204b033873691d675e6d153bf7e71 | |
parent | a40160b8f8930dbe2a0abde4b45e5796264f5782 (diff) | |
download | sink-65131b9470455ae52a86d811882ca1d97c4a899c.tar.gz sink-65131b9470455ae52a86d811882ca1d97c4a899c.zip |
Use Async::while
-rw-r--r-- | dummyresource/resourcefactory.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp index d2b0c14..c0395b7 100644 --- a/dummyresource/resourcefactory.cpp +++ b/dummyresource/resourcefactory.cpp | |||
@@ -210,26 +210,17 @@ private slots: | |||
210 | 210 | ||
211 | Async::Job<void> processPipeline() | 211 | Async::Job<void> processPipeline() |
212 | { | 212 | { |
213 | auto job = Async::start<void>([this](Async::Future<void> &future) { | 213 | //Go through all message queues |
214 | //An async for loop. Go through all message queues | 214 | auto it = QSharedPointer<QListIterator<MessageQueue*> >::create(mCommandQueues); |
215 | //TODO: replace by Async::foreach | 215 | return Async::dowhile<void>( |
216 | auto it = QSharedPointer<QListIterator<MessageQueue*> >::create(mCommandQueues); | 216 | [it]() { return it->hasNext(); }, |
217 | asyncWhile([&, it](std::function<void(bool)> forCallback) { | 217 | [it, this](Async::Future<void> &future) { |
218 | if (it->hasNext()) { | 218 | auto queue = it->next(); |
219 | auto queue = it->next(); | 219 | processQueue(queue).then<void>([&future]() { |
220 | processQueue(queue).then<void>([forCallback]() { | 220 | future.setFinished(); |
221 | forCallback(false); | 221 | }).exec(); |
222 | }).exec(); | 222 | } |
223 | } else { | 223 | ); |
224 | forCallback(true); | ||
225 | } | ||
226 | }, | ||
227 | [&future]() { //while complete | ||
228 | future.setFinished(); | ||
229 | }); | ||
230 | |||
231 | }); | ||
232 | return job; | ||
233 | } | 224 | } |
234 | 225 | ||
235 | private: | 226 | private: |