From ad1c7c8695a57bf8a90955f7840f075e196cbba9 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 19 Jan 2015 19:27:14 +0100 Subject: Async: comments, default error job implementation. --- async/src/async.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'async/src') diff --git a/async/src/async.h b/async/src/async.h index e4b06a9..a528571 100644 --- a/async/src/async.h +++ b/async/src/async.h @@ -31,6 +31,11 @@ #include +/* + * TODO: on .then and potentially others: support for ThenTask without future argument and return value which makes it implicitly a sync continuation. Useful for typical value consumer continuations. + * TODO: error continuation on .then and others. + * TODO: instead of passing the future objects callbacks could be provided for result reporting (we can still use the future object internally + */ namespace Async { template @@ -157,6 +162,18 @@ Job null() return Async::start([](Async::Future &future) {future.setFinished();}); } +/** + * An error job. + * + * An async error. + * + */ +template +Job error(int errorCode = 1, const QString &errorMessage = QString()) +{ + return Async::start([errorCode, errorMessage](Async::Future &future) {future.setError(errorCode, errorMessage);}); +} + class JobBase { template @@ -225,6 +242,8 @@ public: template Job then(ThenTask func, ErrorHandler errorFunc = ErrorHandler()) { + //FIXME are we leaking the executor? + //The executor is copied with ever job instance, so use a sharedpointer? return Job(new Private::ThenExecutor(func, errorFunc, mExecutor)); } @@ -275,6 +294,7 @@ namespace Async { template Job start(ThenTask func) { + //FIXME we're leaking the exucutor, use a shared pointer return Job(new Private::ThenExecutor(func)); } @@ -287,7 +307,7 @@ Future* Executor::chainup() mPrev->exec(); return static_cast*>(mPrev->result()); } else { - return 0; + return nullptr; } } -- cgit v1.2.3