diff options
author | Dan Vrátil <dvratil@redhat.com> | 2015-02-08 13:18:38 +0100 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2015-02-09 14:33:45 +0100 |
commit | bdd7ff7bf44ee6d0a5d8567c2aec97418c72a899 (patch) | |
tree | 02f54d7964359a309c0878644c93a1d28422b623 /async/src | |
parent | 800f38923a4b03f3b22639ba169afbe5edb6c9f5 (diff) | |
download | sink-bdd7ff7bf44ee6d0a5d8567c2aec97418c72a899.tar.gz sink-bdd7ff7bf44ee6d0a5d8567c2aec97418c72a899.zip |
Async: move public API implementation
Diffstat (limited to 'async/src')
-rw-r--r-- | async/src/async.h | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/async/src/async.h b/async/src/async.h index 95b28d7..9a2f721 100644 --- a/async/src/async.h +++ b/async/src/async.h | |||
@@ -183,12 +183,7 @@ Job<Out> start(ThenTask<Out> func); | |||
183 | * | 183 | * |
184 | */ | 184 | */ |
185 | template<typename Out> | 185 | template<typename Out> |
186 | Job<Out> null() | 186 | Job<Out> null(); |
187 | { | ||
188 | return Async::start<Out>([](Async::Future<Out> &future) { | ||
189 | future.setFinished(); | ||
190 | }); | ||
191 | } | ||
192 | 187 | ||
193 | /** | 188 | /** |
194 | * An error job. | 189 | * An error job. |
@@ -197,10 +192,7 @@ Job<Out> null() | |||
197 | * | 192 | * |
198 | */ | 193 | */ |
199 | template<typename Out> | 194 | template<typename Out> |
200 | Job<Out> error(int errorCode = 1, const QString &errorMessage = QString()) | 195 | Job<Out> error(int errorCode = 1, const QString &errorMessage = QString()); |
201 | { | ||
202 | return Async::start<Out>([errorCode, errorMessage](Async::Future<Out> &future) {future.setError(errorCode, errorMessage);}); | ||
203 | } | ||
204 | 196 | ||
205 | class JobBase | 197 | class JobBase |
206 | { | 198 | { |
@@ -370,6 +362,25 @@ Job<Out> start(SyncThenTask<Out> func) | |||
370 | return Job<Out>(Private::ExecutorBasePtr(new Private::SyncThenExecutor<Out>(func, ErrorHandler(), Private::ExecutorBasePtr()))); | 362 | return Job<Out>(Private::ExecutorBasePtr(new Private::SyncThenExecutor<Out>(func, ErrorHandler(), Private::ExecutorBasePtr()))); |
371 | } | 363 | } |
372 | 364 | ||
365 | template<typename Out> | ||
366 | Job<Out> null() | ||
367 | { | ||
368 | return Async::start<Out>( | ||
369 | [](Async::Future<Out> &future) { | ||
370 | future.setFinished(); | ||
371 | }); | ||
372 | } | ||
373 | |||
374 | template<typename Out> | ||
375 | Job<Out> error(int errorCode, const QString &errorMessage) | ||
376 | { | ||
377 | return Async::start<Out>( | ||
378 | [errorCode, errorMessage](Async::Future<Out> &future) { | ||
379 | future.setError(errorCode, errorMessage); | ||
380 | }); | ||
381 | } | ||
382 | |||
383 | |||
373 | namespace Private { | 384 | namespace Private { |
374 | 385 | ||
375 | template<typename PrevOut, typename Out, typename ... In> | 386 | template<typename PrevOut, typename Out, typename ... In> |