Repository: mesos Updated Branches: refs/heads/master 37b9676c8 -> abda779d3
Added missing 'defer' helpers. Fixes compilation issue when building with gcc 4.4, see MESOS-1692 for more details. Review: https://reviews.apache.org/r/24569 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/abda779d Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/abda779d Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/abda779d Branch: refs/heads/master Commit: abda779d39cfa124801a7e94ab454b1bc2789237 Parents: 37b9676 Author: Benjamin Hindman <[email protected]> Authored: Mon Aug 11 11:43:28 2014 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Mon Aug 11 21:44:56 2014 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/include/process/defer.hpp | 49 ++++++++++++++++++--- 3rdparty/libprocess/include/process/future.hpp | 6 +++ 2 files changed, 48 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/abda779d/3rdparty/libprocess/include/process/defer.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/defer.hpp b/3rdparty/libprocess/include/process/defer.hpp index dce7f3b..ebe6f2d 100644 --- a/3rdparty/libprocess/include/process/defer.hpp +++ b/3rdparty/libprocess/include/process/defer.hpp @@ -343,7 +343,7 @@ inline void dispatcher( #define TEMPLATE(Z, N, DATA) \ template <ENUM_PARAMS(N, typename A)> \ - void CAT(invoker, N)( \ + void CAT(vinvoker, N)( \ ProcessBase* _, \ const std::tr1::function<void(ENUM_PARAMS(N, A))>& f, \ ENUM_BINARY_PARAMS(N, A, a)) \ @@ -351,20 +351,55 @@ inline void dispatcher( f(ENUM_PARAMS(N, a)); \ } \ \ + template <typename R, ENUM_PARAMS(N, typename A)> \ + void CAT(invoker, N)( \ + ProcessBase* _, \ + const std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>& f, \ + const std::tr1::shared_ptr<Promise<R> >& promise, \ + ENUM_BINARY_PARAMS(N, A, a)) \ + { \ + if (promise->future().hasDiscard()) { \ + promise->discard(); \ + } else { \ + promise->set(f(ENUM_PARAMS(N, a))); \ + } \ + } \ + \ template <ENUM_PARAMS(N, typename A)> \ - void CAT(dispatcher, N)( \ + void CAT(vdispatcher, N)( \ const UPID& pid, \ const std::tr1::function<void(ENUM_PARAMS(N, A))>& f, \ ENUM_BINARY_PARAMS(N, A, a)) \ { \ std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > invoker( \ new std::tr1::function<void(ProcessBase*)>( \ - std::tr1::bind(&internal::CAT(invoker, N)<ENUM_PARAMS(N, A)>, \ + std::tr1::bind(&internal::CAT(vinvoker, N)<ENUM_PARAMS(N, A)>, \ + std::tr1::placeholders::_1, \ + f, \ + ENUM_PARAMS(N, a)))); \ + \ + internal::dispatch(pid, invoker); \ + } \ + \ + template <typename R, ENUM_PARAMS(N, typename A)> \ + Future<R> CAT(dispatcher, N)( \ + const UPID& pid, \ + const std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>& f, \ + ENUM_BINARY_PARAMS(N, A, a)) \ + { \ + std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>()); \ + \ + std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > invoker( \ + new std::tr1::function<void(ProcessBase*)>( \ + std::tr1::bind(&internal::CAT(invoker, N)<R, ENUM_PARAMS(N, A)>, \ std::tr1::placeholders::_1, \ f, \ + promise, \ ENUM_PARAMS(N, a)))); \ \ internal::dispatch(pid, invoker); \ + \ + return promise->future(); \ } REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9. @@ -421,7 +456,7 @@ inline Deferred<void(void)> defer(const std::tr1::function<void(void)>& f) const std::tr1::function<void(ENUM_PARAMS(N, A))>& f) \ { \ return std::tr1::function<void(ENUM_PARAMS(N, A))>( \ - std::tr1::bind(&internal::CAT(dispatcher, N)<ENUM_PARAMS(N, A)>, \ + std::tr1::bind(&internal::CAT(vdispatcher, N)<ENUM_PARAMS(N, A)>, \ pid, \ f, \ ENUM_BINARY_PARAMS(N, internal::_, () INTERCEPT))); \ @@ -433,7 +468,7 @@ inline Deferred<void(void)> defer(const std::tr1::function<void(void)>& f) { \ if (__process__ != NULL) { \ return std::tr1::function<void(ENUM_PARAMS(N, A))>( \ - std::tr1::bind(&internal::CAT(dispatcher, N)<ENUM_PARAMS(N, A)>, \ + std::tr1::bind(&internal::CAT(vdispatcher, N)<ENUM_PARAMS(N, A)>, \ __process__->self(), \ f, \ ENUM_BINARY_PARAMS(N, internal::_, () INTERCEPT))); \ @@ -448,7 +483,7 @@ inline Deferred<void(void)> defer(const std::tr1::function<void(void)>& f) const std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>& f) \ { \ return std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>( \ - std::tr1::bind(&internal::CAT(dispatcher, N)<ENUM_PARAMS(N, A)>, \ + std::tr1::bind(&internal::CAT(dispatcher, N)<R, ENUM_PARAMS(N, A)>, \ pid, \ f, \ ENUM_BINARY_PARAMS(N, internal::_, () INTERCEPT))); \ @@ -460,7 +495,7 @@ inline Deferred<void(void)> defer(const std::tr1::function<void(void)>& f) { \ if (__process__ != NULL) { \ return std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>( \ - std::tr1::bind(&internal::CAT(dispatcher, N)<ENUM_PARAMS(N, A)>, \ + std::tr1::bind(&internal::CAT(dispatcher, N)<R, ENUM_PARAMS(N, A)>, \ __process__->self(), \ f, \ ENUM_BINARY_PARAMS(N, internal::_, () INTERCEPT))); \ http://git-wip-us.apache.org/repos/asf/mesos/blob/abda779d/3rdparty/libprocess/include/process/future.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp index db7fcbc..46ae16b 100644 --- a/3rdparty/libprocess/include/process/future.hpp +++ b/3rdparty/libprocess/include/process/future.hpp @@ -327,6 +327,12 @@ public: return then(lambda::function<X(const T&)>(lambda::bind(f))); } + template <typename X> + Future<X> then(const Deferred<Future<X>(T)>& f) const + { + return then(lambda::function<Future<X>(const T&)>(f)); + } + #if __cplusplus >= 201103L private: template <typename F, typename X = typename internal::unwrap<typename std::result_of<F(const T&)>::type>::type> // NOLINT(whitespace/line_length)
