summaryrefslogtreecommitdiffstats
path: root/async/src
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-19 12:22:28 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-19 12:22:28 +0200
commit453526c7553c650f9a5bb3fe4452306d9dd3740f (patch)
treefc132ba610bcfa341ea21b3c0f103734cff2327d /async/src
parent12d24dabb8763deed1ab2372d7b69765822b14a5 (diff)
downloadsink-453526c7553c650f9a5bb3fe4452306d9dd3740f.tar.gz
sink-453526c7553c650f9a5bb3fe4452306d9dd3740f.zip
Fixed void async each.
Diffstat (limited to 'async/src')
-rw-r--r--async/src/async.h4
-rw-r--r--async/src/async_impl.h14
2 files changed, 16 insertions, 2 deletions
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:
193 void run(const ExecutionPtr &execution); 193 void run(const ExecutionPtr &execution);
194private: 194private:
195 EachTask<Out, In> mFunc; 195 EachTask<Out, In> mFunc;
196 QVector<Async::FutureWatcher<PrevOut>*> mFutureWatchers; 196 QVector<Async::FutureWatcher<Out>*> mFutureWatchers;
197}; 197};
198 198
199template<typename Out, typename In> 199template<typename Out, typename In>
@@ -729,7 +729,7 @@ void EachExecutor<PrevOut, Out, In>::run(const ExecutionPtr &execution)
729 const int index = mFutureWatchers.indexOf(fw); 729 const int index = mFutureWatchers.indexOf(fw);
730 assert(index > -1); 730 assert(index > -1);
731 mFutureWatchers.removeAt(index); 731 mFutureWatchers.removeAt(index);
732 out->setValue(out->value() + future.value()); 732 Async::detail::aggregateFutureValue<Out>(fw->future(), *out);
733 if (mFutureWatchers.isEmpty()) { 733 if (mFutureWatchers.isEmpty()) {
734 out->setFinished(); 734 out->setFinished();
735 } 735 }
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<T> &in, Async::Future<T> &out)
60 // noop 60 // noop
61} 61}
62 62
63template<typename T>
64inline typename std::enable_if<!std::is_void<T>::value, void>::type
65aggregateFutureValue(const Async::Future<T> &in, Async::Future<T> &out)
66{
67 out.setValue(out.value() + in.value());
68}
69
70template<typename T>
71inline typename std::enable_if<std::is_void<T>::value, void>::type
72aggregateFutureValue(const Async::Future<T> &in, Async::Future<T> &out)
73{
74 // noop
75}
76
63} // namespace Detail 77} // namespace Detail
64 78
65} // namespace Async 79} // namespace Async