summaryrefslogtreecommitdiffstats
path: root/async/src/async.h
diff options
context:
space:
mode:
Diffstat (limited to 'async/src/async.h')
-rw-r--r--async/src/async.h31
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 */
185template<typename Out> 185template<typename Out>
186Job<Out> null() 186Job<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 */
199template<typename Out> 194template<typename Out>
200Job<Out> error(int errorCode = 1, const QString &errorMessage = QString()) 195Job<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
205class JobBase 197class 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
365template<typename Out>
366Job<Out> null()
367{
368 return Async::start<Out>(
369 [](Async::Future<Out> &future) {
370 future.setFinished();
371 });
372}
373
374template<typename Out>
375Job<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
373namespace Private { 384namespace Private {
374 385
375template<typename PrevOut, typename Out, typename ... In> 386template<typename PrevOut, typename Out, typename ... In>