summaryrefslogtreecommitdiffstats
path: root/async/src
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-27 11:19:10 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-27 11:19:10 +0200
commit0a554aabb94cef6f7c4528534549c2a23514a44e (patch)
treed170ceb61769302808774f709dfa046a1660f808 /async/src
parented73e44d5ee7aaaeaa5130a08243909f2d45dcce (diff)
downloadsink-0a554aabb94cef6f7c4528534549c2a23514a44e.tar.gz
sink-0a554aabb94cef6f7c4528534549c2a23514a44e.zip
Async: iterate to easily iterate over a container.
Diffstat (limited to 'async/src')
-rw-r--r--async/src/async.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/async/src/async.h b/async/src/async.h
index 62fb463..d6a74c0 100644
--- a/async/src/async.h
+++ b/async/src/async.h
@@ -276,6 +276,13 @@ Job<void> dowhile(Condition condition, ThenTask<void> func);
276 */ 276 */
277Job<void> dowhile(ThenTask<bool> body); 277Job<void> dowhile(ThenTask<bool> body);
278 278
279/**
280 * Iterate over a container.
281 *
282 * Use in conjunction with .each
283 */
284template<typename Out>
285Job<Out> iterate(const Out &container);
279 286
280/** 287/**
281 * A null job. 288 * A null job.
@@ -577,6 +584,15 @@ Job<Out> error(int errorCode, const QString &errorMessage)
577 }); 584 });
578} 585}
579 586
587template<typename Out>
588Job<Out> iterate(const Out &container)
589{
590 return Async::start<Out>(
591 [container]() {
592 return container;
593 });
594}
595
580 596
581namespace Private { 597namespace Private {
582 598