From 453526c7553c650f9a5bb3fe4452306d9dd3740f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 19 Apr 2015 12:22:28 +0200 Subject: Fixed void async each. --- async/src/async.h | 4 ++-- async/src/async_impl.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'async/src') diff --git a/async/src/async.h b/async/src/async.h index a72d058..62fb463 100644 --- a/async/src/async.h +++ b/async/src/async.h @@ -193,7 +193,7 @@ public: void run(const ExecutionPtr &execution); private: EachTask mFunc; - QVector*> mFutureWatchers; + QVector*> mFutureWatchers; }; template @@ -729,7 +729,7 @@ void EachExecutor::run(const ExecutionPtr &execution) const int index = mFutureWatchers.indexOf(fw); assert(index > -1); mFutureWatchers.removeAt(index); - out->setValue(out->value() + future.value()); + Async::detail::aggregateFutureValue(fw->future(), *out); if (mFutureWatchers.isEmpty()) { out->setFinished(); } diff --git a/async/src/async_impl.h b/async/src/async_impl.h index eccbc9b..8c74193 100644 --- a/async/src/async_impl.h +++ b/async/src/async_impl.h @@ -60,6 +60,20 @@ copyFutureValue(const Async::Future &in, Async::Future &out) // noop } +template +inline typename std::enable_if::value, void>::type +aggregateFutureValue(const Async::Future &in, Async::Future &out) +{ + out.setValue(out.value() + in.value()); +} + +template +inline typename std::enable_if::value, void>::type +aggregateFutureValue(const Async::Future &in, Async::Future &out) +{ + // noop +} + } // namespace Detail } // namespace Async -- cgit v1.2.3