diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-27 11:19:10 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-27 11:19:10 +0200 |
commit | 0a554aabb94cef6f7c4528534549c2a23514a44e (patch) | |
tree | d170ceb61769302808774f709dfa046a1660f808 /async/src | |
parent | ed73e44d5ee7aaaeaa5130a08243909f2d45dcce (diff) | |
download | sink-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.h | 16 |
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 | */ |
277 | Job<void> dowhile(ThenTask<bool> body); | 277 | Job<void> dowhile(ThenTask<bool> body); |
278 | 278 | ||
279 | /** | ||
280 | * Iterate over a container. | ||
281 | * | ||
282 | * Use in conjunction with .each | ||
283 | */ | ||
284 | template<typename Out> | ||
285 | Job<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 | ||
587 | template<typename Out> | ||
588 | Job<Out> iterate(const Out &container) | ||
589 | { | ||
590 | return Async::start<Out>( | ||
591 | [container]() { | ||
592 | return container; | ||
593 | }); | ||
594 | } | ||
595 | |||
580 | 596 | ||
581 | namespace Private { | 597 | namespace Private { |
582 | 598 | ||