summaryrefslogtreecommitdiffstats
path: root/async/src/async_impl.h
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2015-02-20 13:58:03 +0100
committerDan Vrátil <dvratil@redhat.com>2015-02-20 14:00:49 +0100
commit8e6f41f851ae058dea63fbc9b9f523ec9fd1a4fb (patch)
treecbe403f4aaa9498389ab0ddba6af611b99dac98c /async/src/async_impl.h
parent1da08ebfe267313015c201fd1106f891af554e14 (diff)
downloadsink-8e6f41f851ae058dea63fbc9b9f523ec9fd1a4fb.tar.gz
sink-8e6f41f851ae058dea63fbc9b9f523ec9fd1a4fb.zip
Async: allow appending existing Job objects to the Job chain
Now it's possible to do something like Job<int, int> job = createSomeJob(); auto main = Async::start<int>(....).then(job); Previously the 'job' would have to be wrapped in a ThenTask-like lambda (which is what we still do internally), but with this new syntax it's possible to append another job chain to existing chain easilly. This syntax is available for all task types.
Diffstat (limited to 'async/src/async_impl.h')
-rw-r--r--async/src/async_impl.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/async/src/async_impl.h b/async/src/async_impl.h
index 58f6ced..eccbc9b 100644
--- a/async/src/async_impl.h
+++ b/async/src/async_impl.h
@@ -19,6 +19,7 @@
19#define ASYNC_IMPL_H 19#define ASYNC_IMPL_H
20 20
21#include "async.h" 21#include "async.h"
22#include <type_traits>
22 23
23namespace Async { 24namespace Async {
24 25
@@ -45,6 +46,20 @@ struct prevOut {
45 using type = typename std::tuple_element<0, std::tuple<T ..., void>>::type; 46 using type = typename std::tuple_element<0, std::tuple<T ..., void>>::type;
46}; 47};
47 48
49template<typename T>
50inline typename std::enable_if<!std::is_void<T>::value, void>::type
51copyFutureValue(const Async::Future<T> &in, Async::Future<T> &out)
52{
53 out.setValue(in.value());
54}
55
56template<typename T>
57inline typename std::enable_if<std::is_void<T>::value, void>::type
58copyFutureValue(const Async::Future<T> &in, Async::Future<T> &out)
59{
60 // noop
61}
62
48} // namespace Detail 63} // namespace Detail
49 64
50} // namespace Async 65} // namespace Async