You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/04/26 21:43:36 UTC

[03/10] mesos git commit: Removed pre-C++11 codepath in libprocess.

Removed pre-C++11 codepath in libprocess.

Review: https://reviews.apache.org/r/33561


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5ab8ff81
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5ab8ff81
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5ab8ff81

Branch: refs/heads/master
Commit: 5ab8ff815a8481a24ce46ae6e98f845236f8e627
Parents: d19a9d5
Author: Michael Park <mc...@gmail.com>
Authored: Sun Apr 26 12:22:39 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sun Apr 26 12:22:42 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/Makefile.am         |   8 -
 .../libprocess/include/process/c++11/defer.hpp  | 262 -----------
 .../include/process/c++11/deferred.hpp          | 270 ------------
 .../libprocess/include/process/c++11/delay.hpp  |  88 ----
 .../include/process/c++11/dispatch.hpp          | 389 -----------------
 .../include/process/c++11/executor.hpp          |  68 ---
 3rdparty/libprocess/include/process/collect.hpp |  83 ----
 3rdparty/libprocess/include/process/defer.hpp   | 435 ++++---------------
 .../libprocess/include/process/deferred.hpp     | 298 +++++++++----
 3rdparty/libprocess/include/process/delay.hpp   |  46 +-
 .../libprocess/include/process/dispatch.hpp     | 337 ++++++--------
 .../libprocess/include/process/executor.hpp     | 222 +---------
 3rdparty/libprocess/include/process/future.hpp  | 260 -----------
 .../libprocess/include/process/timeseries.hpp   |  10 -
 3rdparty/libprocess/src/io.cpp                  | 156 -------
 3rdparty/libprocess/src/tests/process_tests.cpp |  16 -
 16 files changed, 440 insertions(+), 2508 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/Makefile.am b/3rdparty/libprocess/include/Makefile.am
index 3da3e6c..8aab059 100644
--- a/3rdparty/libprocess/include/Makefile.am
+++ b/3rdparty/libprocess/include/Makefile.am
@@ -52,11 +52,3 @@ nobase_include_HEADERS =		\
   process/timeout.hpp			\
   process/timer.hpp			\
   process/timeseries.hpp
-
-# C++11 Headers.
-nobase_include_HEADERS +=		\
-  process/c++11/defer.hpp		\
-  process/c++11/deferred.hpp		\
-  process/c++11/delay.hpp		\
-  process/c++11/dispatch.hpp		\
-  process/c++11/executor.hpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/process/c++11/defer.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/c++11/defer.hpp b/3rdparty/libprocess/include/process/c++11/defer.hpp
deleted file mode 100644
index 7b4dd07..0000000
--- a/3rdparty/libprocess/include/process/c++11/defer.hpp
+++ /dev/null
@@ -1,262 +0,0 @@
-#ifndef __PROCESS_DEFER_HPP__
-#define __PROCESS_DEFER_HPP__
-
-#include <functional>
-#include <memory>
-
-#include <process/deferred.hpp>
-#include <process/dispatch.hpp>
-#include <process/executor.hpp>
-
-#include <stout/preprocessor.hpp>
-
-namespace process {
-
-// The defer mechanism is very similar to the dispatch mechanism (see
-// dispatch.hpp), however, rather than scheduling the method to get
-// invoked, the defer mechanism returns a 'Deferred' object that when
-// invoked does the underlying dispatch.
-
-// First, definitions of defer for methods returning void:
-
-template <typename T>
-Deferred<void(void)> defer(
-    const PID<T>& pid,
-    void (T::*method)(void))
-{
-  return Deferred<void(void)>([=] () {
-    dispatch(pid, method);
-  });
-}
-
-
-template <typename T>
-Deferred<void(void)> defer(
-    const Process<T>& process,
-    void (T::*method)(void))
-{
-  return defer(process.self(), method);
-}
-
-
-template <typename T>
-Deferred<void(void)> defer(
-    const Process<T>* process,
-    void (T::*method)(void))
-{
-  return defer(process->self(), method);
-}
-
-
-// Due to a bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933)
-// with variadic templates and lambdas, we still need to do
-// preprocessor expansions. In addition, due to a bug with clang (or
-// libc++) we can't use std::bind with a std::function so we have to
-// explicitely use the std::function<R(P...)>::operator() (see
-// http://stackoverflow.com/questions/20097616/stdbind-to-a-stdfunction-crashes-with-clang).
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto defer(const PID<T>& pid,                                         \
-             void (T::*method)(ENUM_PARAMS(N, P)),                      \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> _Deferred<decltype(std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::function<void(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \
-  {                                                                     \
-    std::function<void(ENUM_PARAMS(N, P))> f(                           \
-        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
-          dispatch(pid, method, ENUM_PARAMS(N, p));                     \
-        });                                                             \
-    return std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \
-  }                                                                     \
-                                                                        \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto defer(const Process<T>& process,                                 \
-             void (T::*method)(ENUM_PARAMS(N, P)),                      \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> decltype(defer(process.self(), method, ENUM_PARAMS(N, a)))       \
-  {                                                                     \
-    return defer(process.self(), method, ENUM_PARAMS(N, a));            \
-  }                                                                     \
-                                                                        \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto defer(const Process<T>* process,                                 \
-             void (T::*method)(ENUM_PARAMS(N, P)),                      \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> decltype(defer(process->self(), method, ENUM_PARAMS(N, a)))      \
-  {                                                                     \
-    return defer(process->self(), method, ENUM_PARAMS(N, a));           \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-
-// Next, definitions of defer for methods returning future:
-
-template <typename R, typename T>
-Deferred<Future<R>(void)>
-defer(const PID<T>& pid, Future<R> (T::*method)(void))
-{
-  return Deferred<Future<R>(void)>([=] () {
-    return dispatch(pid, method);
-  });
-}
-
-template <typename R, typename T>
-Deferred<Future<R>(void)>
-defer(const Process<T>& process, Future<R> (T::*method)(void))
-{
-  return defer(process.self(), method);
-}
-
-template <typename R, typename T>
-Deferred<Future<R>(void)>
-defer(const Process<T>* process, Future<R> (T::*method)(void))
-{
-  return defer(process->self(), method);
-}
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto defer(const PID<T>& pid,                                         \
-             Future<R> (T::*method)(ENUM_PARAMS(N, P)),                 \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \
-  {                                                                     \
-    std::function<Future<R>(ENUM_PARAMS(N, P))> f(                      \
-        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
-          return dispatch(pid, method, ENUM_PARAMS(N, p));              \
-        });                                                             \
-    return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto defer(const Process<T>& process,                                 \
-             Future<R> (T::*method)(ENUM_PARAMS(N, P)),                 \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> decltype(defer(process.self(), method, ENUM_PARAMS(N, a)))       \
-  {                                                                     \
-    return defer(process.self(), method, ENUM_PARAMS(N, a));            \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto defer(const Process<T>* process,                                 \
-             Future<R> (T::*method)(ENUM_PARAMS(N, P)),                 \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> decltype(defer(process->self(), method, ENUM_PARAMS(N, a)))      \
-  {                                                                     \
-    return defer(process->self(), method, ENUM_PARAMS(N, a));           \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-
-// Finaly, definitions of defer for methods returning a value:
-
-template <typename R, typename T>
-Deferred<Future<R>(void)>
-defer(const PID<T>& pid, R (T::*method)(void))
-{
-  return Deferred<Future<R>(void)>([=] () {
-    return dispatch(pid, method);
-  });
-}
-
-template <typename R, typename T>
-Deferred<Future<R>(void)>
-defer(const Process<T>& process, R (T::*method)(void))
-{
-  return defer(process.self(), method);
-}
-
-template <typename R, typename T>
-Deferred<Future<R>(void)>
-defer(const Process<T>* process, R (T::*method)(void))
-{
-  return defer(process->self(), method);
-}
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto defer(const PID<T>& pid,                                         \
-             R (T::*method)(ENUM_PARAMS(N, P)),                         \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \
-  {                                                                     \
-    std::function<Future<R>(ENUM_PARAMS(N, P))> f(                      \
-        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
-          return dispatch(pid, method, ENUM_PARAMS(N, p));              \
-        });                                                             \
-    return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto                                                                  \
-  defer(const Process<T>& process,                                      \
-        R (T::*method)(ENUM_PARAMS(N, P)),                              \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
-    -> decltype(defer(process.self(), method, ENUM_PARAMS(N, a)))       \
-  {                                                                     \
-    return defer(process.self(), method, ENUM_PARAMS(N, a));            \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  auto                                                                  \
-  defer(const Process<T>* process,                                      \
-        R (T::*method)(ENUM_PARAMS(N, P)),                              \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
-    -> decltype(defer(process->self(), method, ENUM_PARAMS(N, a)))      \
-  {                                                                     \
-    return defer(process->self(), method, ENUM_PARAMS(N, a));           \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-
-// Now we define defer calls for functors (with and without a PID):
-
-template <typename F>
-_Deferred<F> defer(const UPID& pid, F&& f)
-{
-  return _Deferred<F>(pid, std::forward<F>(f));
-}
-
-
-template <typename F>
-_Deferred<F> defer(F&& f)
-{
-  if (__process__ != NULL) {
-    return defer(__process__->self(), std::forward<F>(f));
-  }
-
-  return __executor__->defer(std::forward<F>(f));
-}
-
-} // namespace process {
-
-#endif // __PROCESS_DEFER_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/process/c++11/deferred.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/c++11/deferred.hpp b/3rdparty/libprocess/include/process/c++11/deferred.hpp
deleted file mode 100644
index 352205b..0000000
--- a/3rdparty/libprocess/include/process/c++11/deferred.hpp
+++ /dev/null
@@ -1,270 +0,0 @@
-#ifndef __PROCESS_DEFERRED_HPP__
-#define __PROCESS_DEFERRED_HPP__
-
-#include <functional>
-
-#include <process/dispatch.hpp>
-#include <process/pid.hpp>
-
-#include <stout/preprocessor.hpp>
-
-namespace process {
-
-// Acts like a function call but runs within an asynchronous execution
-// context such as an Executor or a ProcessBase (enforced because only
-// an executor or the 'defer' routines are allowed to create them).
-template <typename F>
-struct Deferred : std::function<F>
-{
-private:
-  friend class Executor;
-
-  template <typename G> friend struct _Deferred;
-
-  // TODO(benh): Consider removing these in favor of having these
-  // functions return _Deferred.
-  template <typename T>
-  friend Deferred<void(void)>
-  defer(const PID<T>& pid, void (T::*method)(void));
-
-  template <typename R, typename T>
-  friend Deferred<Future<R>(void)>
-  defer(const PID<T>& pid, Future<R> (T::*method)(void));
-
-  template <typename R, typename T>
-  friend Deferred<Future<R>(void)>
-  defer(const PID<T>& pid, R (T::*method)(void));
-
-  /*implicit*/ Deferred(const std::function<F>& f) : std::function<F>(f) {}
-};
-
-
-// We need an intermeidate "deferred" type because when constructing a
-// Deferred we won't always know the underlying function type (for
-// example, if we're being passed a std::bind or a lambda). A lambda
-// won't always implicitly convert to a std::function so instead we
-// hold onto the functor type F and let the compiler invoke the
-// necessary cast operator (below) when it actually has determined
-// what type is needed. This is similar in nature to how std::bind
-// works with it's intermediate _Bind type (which the pre-C++11
-// implementation relied on).
-template <typename F>
-struct _Deferred
-{
-  operator Deferred<void()> () const
-  {
-    // The 'pid' differentiates an already dispatched functor versus
-    // one which still needs to be dispatched (which is done
-    // below). We have to delay wrapping the dispatch (for example, in
-    // defer.hpp) as long as possible because we don't always know
-    // what type the functor is or is going to be cast to (i.e., a
-    // std::bind might can be cast to functions that do or do not take
-    // arguments which will just be dropped when invoking the
-    // underlying bound function).
-    if (pid.isNone()) {
-      return std::function<void()>(f);
-    }
-
-    // We need to explicitly copy the members otherwise we'll
-    // implicitly copy 'this' which might not exist at invocation.
-    Option<UPID> pid_ = pid;
-    F f_ = f;
-
-    return std::function<void()>(
-        [=] () {
-          dispatch(pid_.get(), std::function<void()>(f_));
-        });
-  }
-
-  operator std::function<void()> () const
-  {
-    if (pid.isNone()) {
-      return std::function<void()>(f);
-    }
-
-    Option<UPID> pid_ = pid;
-    F f_ = f;
-
-    return std::function<void()>(
-        [=] () {
-          dispatch(pid_.get(), std::function<void()>(f_));
-        });
-  }
-
-  template <typename R>
-  operator Deferred<R()> () const
-  {
-    if (pid.isNone()) {
-      return std::function<R()>(f);
-    }
-
-    Option<UPID> pid_ = pid;
-    F f_ = f;
-
-    return std::function<R()>(
-        [=] () {
-          return dispatch(pid_.get(), std::function<R()>(f_));
-        });
-  }
-
-  template <typename R>
-  operator std::function<R()> () const
-  {
-    if (pid.isNone()) {
-      return std::function<R()>(f);
-    }
-
-    Option<UPID> pid_ = pid;
-    F f_ = f;
-
-    return std::function<R()>(
-        [=] () {
-          return dispatch(pid_.get(), std::function<R()>(f_));
-        });
-  }
-
-  // Due to a bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933)
-  // with variadic templates and lambdas, we still need to do
-  // preprocessor expansions. In addition, due to a bug with clang (or
-  // libc++) we can't use std::bind with a std::function so we have to
-  // explicitely use the std::function<R(P...)>::operator() (see
-  // http://stackoverflow.com/questions/20097616/stdbind-to-a-stdfunction-crashes-with-clang).
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <ENUM_PARAMS(N, typename P)>                                 \
-  operator Deferred<void(ENUM_PARAMS(N, P))> () const                   \
-  {                                                                     \
-    if (pid.isNone()) {                                                 \
-      return std::function<void(ENUM_PARAMS(N, P))>(f);                 \
-    }                                                                   \
-                                                                        \
-    Option<UPID> pid_ = pid;                                            \
-    F f_ = f;                                                           \
-                                                                        \
-    return std::function<void(ENUM_PARAMS(N, P))>(                      \
-        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
-          std::function<void()> f__([=] () {                            \
-            f_(ENUM_PARAMS(N, p));                                      \
-          });                                                           \
-          dispatch(pid_.get(), f__);                                    \
-        });                                                             \
-  }                                                                     \
-                                                                        \
-  template <ENUM_PARAMS(N, typename P)>                                 \
-  operator std::function<void(ENUM_PARAMS(N, P))> () const              \
-  {                                                                     \
-    if (pid.isNone()) {                                                 \
-      return std::function<void(ENUM_PARAMS(N, P))>(f);                 \
-    }                                                                   \
-                                                                        \
-    Option<UPID> pid_ = pid;                                            \
-    F f_ = f;                                                           \
-                                                                        \
-    return std::function<void(ENUM_PARAMS(N, P))>(                      \
-        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
-          std::function<void()> f__([=] () {                            \
-            f_(ENUM_PARAMS(N, p));                                      \
-          });                                                           \
-          dispatch(pid_.get(), f__);                                    \
-        });                                                             \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename R, ENUM_PARAMS(N, typename P)>                     \
-  operator Deferred<R(ENUM_PARAMS(N, P))> () const                      \
-  {                                                                     \
-    if (pid.isNone()) {                                                 \
-      return std::function<R(ENUM_PARAMS(N, P))>(f);                    \
-    }                                                                   \
-                                                                        \
-    Option<UPID> pid_ = pid;                                            \
-    F f_ = f;                                                           \
-                                                                        \
-    return std::function<R(ENUM_PARAMS(N, P))>(                         \
-        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
-          std::function<R()> f__([=] () {                               \
-            return f_(ENUM_PARAMS(N, p));                               \
-          });                                                           \
-          return dispatch(pid_.get(), f__);                             \
-        });                                                             \
-  }                                                                     \
-                                                                        \
-  template <typename R, ENUM_PARAMS(N, typename P)>                     \
-  operator std::function<R(ENUM_PARAMS(N, P))> () const                 \
-  {                                                                     \
-    if (pid.isNone()) {                                                 \
-      return std::function<R(ENUM_PARAMS(N, P))>(f);                    \
-    }                                                                   \
-                                                                        \
-    Option<UPID> pid_ = pid;                                            \
-    F f_ = f;                                                           \
-                                                                        \
-    return std::function<R(ENUM_PARAMS(N, P))>(                         \
-        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
-          std::function<R()> f__([=] () {                               \
-            return f_(ENUM_PARAMS(N, p));                               \
-          });                                                           \
-          return dispatch(pid_.get(), f__);                             \
-        });                                                             \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-private:
-  friend class Executor;
-
-  template <typename G>
-  friend _Deferred<G> defer(const UPID& pid, G&& g);
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  friend auto defer(const PID<T>& pid,                                  \
-             void (T::*method)(ENUM_PARAMS(N, P)),                      \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> _Deferred<decltype(std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::function<void(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))>; // NOLINT(whitespace/line_length)
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  friend auto defer(const PID<T>& pid,                                  \
-             Future<R> (T::*method)(ENUM_PARAMS(N, P)),                 \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))>; // NOLINT(whitespace/line_length)
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  friend auto defer(const PID<T>& pid,                                  \
-             R (T::*method)(ENUM_PARAMS(N, P)),                         \
-             ENUM_BINARY_PARAMS(N, A, a))                               \
-    -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))>; // NOLINT(whitespace/line_length)
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-  _Deferred(const UPID& pid, F f) : pid(pid), f(f) {}
-
-  /*implicit*/ _Deferred(F f) : f(f) {}
-
-  Option<UPID> pid;
-  F f;
-};
-
-} // namespace process {
-
-#endif // __PROCESS_DEFERRED_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/process/c++11/delay.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/c++11/delay.hpp b/3rdparty/libprocess/include/process/c++11/delay.hpp
deleted file mode 100644
index 5818e83..0000000
--- a/3rdparty/libprocess/include/process/c++11/delay.hpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef __PROCESS_DELAY_HPP__
-#define __PROCESS_DELAY_HPP__
-
-#include <process/clock.hpp>
-#include <process/dispatch.hpp>
-#include <process/timer.hpp>
-
-#include <stout/duration.hpp>
-#include <stout/preprocessor.hpp>
-
-namespace process {
-
-// The 'delay' mechanism enables you to delay a dispatch to a process
-// for some specified number of seconds. Returns a Timer instance that
-// can be cancelled (but it might have already executed or be
-// executing concurrently).
-
-template <typename T>
-Timer delay(const Duration& duration,
-            const PID<T>& pid,
-            void (T::*method)())
-{
-  return Clock::timer(duration, [=] () {
-    dispatch(pid, method);
-  });
-}
-
-
-template <typename T>
-Timer delay(const Duration& duration,
-            const Process<T>& process,
-            void (T::*method)())
-{
-  return delay(duration, process.self(), method);
-}
-
-
-template <typename T>
-Timer delay(const Duration& duration,
-            const Process<T>* process,
-            void (T::*method)())
-{
-  return delay(duration, process->self(), method);
-}
-
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Timer delay(const Duration& duration,                                 \
-              const PID<T>& pid,                                        \
-              void (T::*method)(ENUM_PARAMS(N, P)),                     \
-              ENUM_BINARY_PARAMS(N, A, a))                              \
-  {                                                                     \
-    return Clock::timer(duration, [=] () {                              \
-      dispatch(pid, method, ENUM_PARAMS(N, a));                         \
-    });                                                                 \
-  }                                                                     \
-                                                                        \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Timer delay(const Duration& duration,                                 \
-              const Process<T>& process,                                \
-              void (T::*method)(ENUM_PARAMS(N, P)),                     \
-              ENUM_BINARY_PARAMS(N, A, a))                              \
-  {                                                                     \
-    return delay(duration, process.self(), method, ENUM_PARAMS(N, a));  \
-  }                                                                     \
-                                                                        \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Timer delay(const Duration& duration,                                 \
-              const Process<T>* process,                                \
-              void (T::*method)(ENUM_PARAMS(N, P)),                     \
-              ENUM_BINARY_PARAMS(N, A, a))                              \
-  {                                                                     \
-    return delay(duration, process->self(), method, ENUM_PARAMS(N, a)); \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-} // namespace process {
-
-#endif // __PROCESS_DELAY_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/process/c++11/dispatch.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/c++11/dispatch.hpp b/3rdparty/libprocess/include/process/c++11/dispatch.hpp
deleted file mode 100644
index 99de0e9..0000000
--- a/3rdparty/libprocess/include/process/c++11/dispatch.hpp
+++ /dev/null
@@ -1,389 +0,0 @@
-#ifndef __PROCESS_DISPATCH_HPP__
-#define __PROCESS_DISPATCH_HPP__
-
-#include <functional>
-#include <memory> // TODO(benh): Replace shared_ptr with unique_ptr.
-#include <string>
-
-#include <process/process.hpp>
-
-#include <stout/preprocessor.hpp>
-
-namespace process {
-
-// The dispatch mechanism enables you to "schedule" a method to get
-// invoked on a process. The result of that method invocation is
-// accessible via the future that is returned by the dispatch method
-// (note, however, that it might not be the _same_ future as the one
-// returned from the method, if the method even returns a future, see
-// below). Assuming some class 'Fibonacci' has a (visible) method
-// named 'compute' that takes an integer, N (and returns the Nth
-// fibonacci number) you might use dispatch like so:
-//
-// PID<Fibonacci> pid = spawn(new Fibonacci(), true); // Use the GC.
-// Future<int> f = dispatch(pid, &Fibonacci::compute, 10);
-//
-// Because the pid argument is "typed" we can ensure that methods are
-// only invoked on processes that are actually of that type. Providing
-// this mechanism for varying numbers of function types and arguments
-// requires support for variadic templates, slated to be released in
-// C++11. Until then, we use the Boost preprocessor macros to
-// accomplish the same thing (all be it less cleanly). See below for
-// those definitions.
-//
-// Dispatching is done via a level of indirection. The dispatch
-// routine itself creates a promise that is passed as an argument to a
-// partially applied 'dispatcher' function (defined below). The
-// dispatcher routines get passed to the actual process via an
-// internal routine called, not suprisingly, 'dispatch', defined
-// below:
-
-namespace internal {
-
-// The internal dispatch routine schedules a function to get invoked
-// within the context of the process associated with the specified pid
-// (first argument), unless that process is no longer valid. Note that
-// this routine does not expect anything in particular about the
-// specified function (second argument). The semantics are simple: the
-// function gets applied/invoked with the process as its first
-// argument. Currently we wrap the function in a shared_ptr but this
-// will probably change in the future to unique_ptr (or a variant).
-void dispatch(
-    const UPID& pid,
-    const std::shared_ptr<std::function<void(ProcessBase*)>>& f,
-    const Option<const std::type_info*>& functionType = None());
-
-} // namespace internal {
-
-
-// Okay, now for the definition of the dispatch routines
-// themselves. For each routine we provide the version in C++11 using
-// variadic templates so the reader can see what the Boost
-// preprocessor macros are effectively providing. Using C++11 closures
-// would shorten these definitions even more.
-//
-// First, definitions of dispatch for methods returning void:
-
-template <typename T>
-void dispatch(
-    const PID<T>& pid,
-    void (T::*method)())
-{
-  std::shared_ptr<std::function<void(ProcessBase*)>> f(
-      new std::function<void(ProcessBase*)>(
-          [=] (ProcessBase* process) {
-            assert(process != NULL);
-            T* t = dynamic_cast<T*>(process);
-            assert(t != NULL);
-            (t->*method)();
-          }));
-
-  internal::dispatch(pid, f, &typeid(method));
-}
-
-template <typename T>
-void dispatch(
-    const Process<T>& process,
-    void (T::*method)())
-{
-  dispatch(process.self(), method);
-}
-
-template <typename T>
-void dispatch(
-    const Process<T>* process,
-    void (T::*method)())
-{
-  dispatch(process->self(), method);
-}
-
-// Due to a bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933)
-// with variadic templates and lambdas, we still need to do
-// preprocessor expansions.
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  void dispatch(                                                        \
-      const PID<T>& pid,                                                \
-      void (T::*method)(ENUM_PARAMS(N, P)),                             \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    std::shared_ptr<std::function<void(ProcessBase*)>> f(               \
-        new std::function<void(ProcessBase*)>(                          \
-            [=] (ProcessBase* process) {                                \
-              assert(process != NULL);                                  \
-              T* t = dynamic_cast<T*>(process);                         \
-              assert(t != NULL);                                        \
-              (t->*method)(ENUM_PARAMS(N, a));                          \
-            }));                                                        \
-                                                                        \
-    internal::dispatch(pid, f, &typeid(method));                        \
-  }                                                                     \
-                                                                        \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  void dispatch(                                                        \
-      const Process<T>& process,                                        \
-      void (T::*method)(ENUM_PARAMS(N, P)),                             \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    dispatch(process.self(), method, ENUM_PARAMS(N, a));                \
-  }                                                                     \
-                                                                        \
-  template <typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  void dispatch(                                                        \
-      const Process<T>* process,                                        \
-      void (T::*method)(ENUM_PARAMS(N, P)),                             \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    dispatch(process->self(), method, ENUM_PARAMS(N, a));               \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-
-// Next, definitions of methods returning a future:
-
-template <typename R, typename T>
-Future<R> dispatch(
-    const PID<T>& pid,
-    Future<R> (T::*method)())
-{
-  std::shared_ptr<Promise<R>> promise(new Promise<R>());
-
-  std::shared_ptr<std::function<void(ProcessBase*)>> f(
-      new std::function<void(ProcessBase*)>(
-          [=] (ProcessBase* process) {
-            assert(process != NULL);
-            T* t = dynamic_cast<T*>(process);
-            assert(t != NULL);
-            promise->associate((t->*method)());
-          }));
-
-  internal::dispatch(pid, f, &typeid(method));
-
-  return promise->future();
-}
-
-template <typename R, typename T>
-Future<R> dispatch(
-    const Process<T>& process,
-    Future<R> (T::*method)(void))
-{
-  return dispatch(process.self(), method);
-}
-
-template <typename R, typename T>
-Future<R> dispatch(
-    const Process<T>* process,
-    Future<R> (T::*method)(void))
-{
-  return dispatch(process->self(), method);
-}
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Future<R> dispatch(                                                   \
-      const PID<T>& pid,                                                \
-      Future<R> (T::*method)(ENUM_PARAMS(N, P)),                        \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    std::shared_ptr<Promise<R>> promise(new Promise<R>());              \
-                                                                        \
-    std::shared_ptr<std::function<void(ProcessBase*)>> f(               \
-        new std::function<void(ProcessBase*)>(                          \
-            [=] (ProcessBase* process) {                                \
-              assert(process != NULL);                                  \
-              T* t = dynamic_cast<T*>(process);                         \
-              assert(t != NULL);                                        \
-              promise->associate((t->*method)(ENUM_PARAMS(N, a)));      \
-            }));                                                        \
-                                                                        \
-    internal::dispatch(pid, f, &typeid(method));                        \
-                                                                        \
-    return promise->future();                                           \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Future<R> dispatch(                                                   \
-      const Process<T>& process,                                        \
-      Future<R> (T::*method)(ENUM_PARAMS(N, P)),                        \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    return dispatch(process.self(), method, ENUM_PARAMS(N, a));         \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Future<R> dispatch(                                                   \
-      const Process<T>* process,                                        \
-      Future<R> (T::*method)(ENUM_PARAMS(N, P)),                        \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    return dispatch(process->self(), method, ENUM_PARAMS(N, a));        \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-
-// Next, definitions of methods returning a value.
-
-template <typename R, typename T>
-Future<R> dispatch(
-    const PID<T>& pid,
-    R (T::*method)(void))
-{
-  std::shared_ptr<Promise<R>> promise(new Promise<R>());
-
-  std::shared_ptr<std::function<void(ProcessBase*)>> f(
-      new std::function<void(ProcessBase*)>(
-          [=] (ProcessBase* process) {
-            assert(process != NULL);
-            T* t = dynamic_cast<T*>(process);
-            assert(t != NULL);
-            promise->set((t->*method)());
-          }));
-
-  internal::dispatch(pid, f, &typeid(method));
-
-  return promise->future();
-}
-
-template <typename R, typename T>
-Future<R> dispatch(
-    const Process<T>& process,
-    R (T::*method)())
-{
-  return dispatch(process.self(), method);
-}
-
-template <typename R, typename T>
-Future<R> dispatch(
-    const Process<T>* process,
-    R (T::*method)())
-{
-  return dispatch(process->self(), method);
-}
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Future<R> dispatch(                                                   \
-      const PID<T>& pid,                                                \
-      R (T::*method)(ENUM_PARAMS(N, P)),                                \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    std::shared_ptr<Promise<R>> promise(new Promise<R>());              \
-                                                                        \
-    std::shared_ptr<std::function<void(ProcessBase*)>> f(               \
-        new std::function<void(ProcessBase*)>(                          \
-            [=] (ProcessBase* process) {                                \
-              assert(process != NULL);                                  \
-              T* t = dynamic_cast<T*>(process);                         \
-              assert(t != NULL);                                        \
-              promise->set((t->*method)(ENUM_PARAMS(N, a)));            \
-            }));                                                        \
-                                                                        \
-    internal::dispatch(pid, f, &typeid(method));                        \
-                                                                        \
-    return promise->future();                                           \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Future<R> dispatch(                                                   \
-      const Process<T>& process,                                        \
-      R (T::*method)(ENUM_PARAMS(N, P)),                                \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    return dispatch(process.self(), method, ENUM_PARAMS(N, a));         \
-  }                                                                     \
-                                                                        \
-  template <typename R,                                                 \
-            typename T,                                                 \
-            ENUM_PARAMS(N, typename P),                                 \
-            ENUM_PARAMS(N, typename A)>                                 \
-  Future<R> dispatch(                                                   \
-      const Process<T>* process,                                        \
-      R (T::*method)(ENUM_PARAMS(N, P)),                                \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    return dispatch(process->self(), method, ENUM_PARAMS(N, a));        \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
-
-inline void dispatch(
-    const UPID& pid,
-    const std::function<void()>& f)
-{
-  std::shared_ptr<std::function<void(ProcessBase*)>> f_(
-      new std::function<void(ProcessBase*)>(
-          [=] (ProcessBase*) {
-            f();
-          }));
-
-  internal::dispatch(pid, f_);
-}
-
-
-template <typename R>
-Future<R> dispatch(
-    const UPID& pid,
-    const std::function<Future<R>()>& f)
-{
-  std::shared_ptr<Promise<R>> promise(new Promise<R>());
-
-  std::shared_ptr<std::function<void(ProcessBase*)>> f_(
-      new std::function<void(ProcessBase*)>(
-          [=] (ProcessBase*) {
-            promise->associate(f());
-          }));
-
-  internal::dispatch(pid, f_);
-
-  return promise->future();
-}
-
-
-template <typename R>
-Future<R> dispatch(
-    const UPID& pid,
-    const std::function<R()>& f)
-{
-  std::shared_ptr<Promise<R>> promise(new Promise<R>());
-
-  std::shared_ptr<std::function<void(ProcessBase*)>> f_(
-      new std::function<void(ProcessBase*)>(
-          [=] (ProcessBase*) {
-            promise->set(f());
-          }));
-
-  internal::dispatch(pid, f_);
-
-  return promise->future();
-}
-
-} // namespace process {
-
-#endif // __PROCESS_DISPATCH_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/process/c++11/executor.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/c++11/executor.hpp b/3rdparty/libprocess/include/process/c++11/executor.hpp
deleted file mode 100644
index 157a1d2..0000000
--- a/3rdparty/libprocess/include/process/c++11/executor.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef __PROCESS_EXECUTOR_HPP__
-#define __PROCESS_EXECUTOR_HPP__
-
-#include <process/defer.hpp>
-#include <process/deferred.hpp>
-#include <process/id.hpp>
-#include <process/process.hpp>
-
-#include <stout/thread.hpp>
-
-namespace process {
-
-// Provides an abstraction that can take a standard function object
-// and defer it without needing a process. Each converted function
-// object will get execute serially with respect to one another when
-// invoked.
-class Executor
-{
-public:
-  Executor() : process(ID::generate("__executor__"))
-  {
-    spawn(process);
-  }
-
-  ~Executor()
-  {
-    terminate(process);
-    wait(process);
-  }
-
-  void stop()
-  {
-    terminate(&process);
-
-    // TODO(benh): Note that this doesn't wait because that could
-    // cause a deadlock ... thus, the semantics here are that no more
-    // dispatches will occur after this function returns but one may
-    // be occuring concurrently.
-  }
-
-  template <typename F>
-  _Deferred<F> defer(F&& f)
-  {
-    return _Deferred<F>(process.self(), std::forward<F>(f));
-  }
-
-
-private:
-  // Not copyable, not assignable.
-  Executor(const Executor&);
-  Executor& operator = (const Executor&);
-
-  ProcessBase process;
-};
-
-
-// Per thread executor pointer. The extra level of indirection from
-// _executor_ to __executor__ is used in order to take advantage of
-// the ThreadLocal operators without needing the extra dereference as
-// well as lazily construct the actual executor.
-extern ThreadLocal<Executor>* _executor_;
-
-#define __executor__                                                    \
-  (*_executor_ == NULL ? *_executor_ = new Executor() : *_executor_)
-
-} // namespace process {
-
-#endif // __PROCESS_EXECUTOR_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/process/collect.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/collect.hpp b/3rdparty/libprocess/include/process/collect.hpp
index 2e2fce6..ca220c3 100644
--- a/3rdparty/libprocess/include/process/collect.hpp
+++ b/3rdparty/libprocess/include/process/collect.hpp
@@ -162,36 +162,6 @@ private:
 };
 
 
-#if __cplusplus < 201103L
-
-template <typename T>
-void _await(
-    const Future<T>& result,
-    Owned<Promise<Nothing>> promise)
-{
-  promise->set(Nothing());
-}
-
-
-template <typename T1, typename T2>
-Future<tuples::tuple<Future<T1>, Future<T2>>> __await(
-    const tuples::tuple<Future<T1>, Future<T2>>& future)
-{
-  return future;
-}
-
-
-// NOTE: We do not use overload (i.e., '__await') here because gcc-4.4
-// cannot resolve the overload when we call 'bind' below.
-template <typename T1, typename T2, typename T3>
-Future<tuples::tuple<Future<T1>, Future<T2>, Future<T3>>> ___await(
-    const tuples::tuple<Future<T1>, Future<T2>, Future<T3>>& future)
-{
-  return future;
-}
-
-#endif // __cplusplus < 201103L
-
 } // namespace internal {
 
 
@@ -226,8 +196,6 @@ inline Future<std::list<Future<T>>> await(
 }
 
 
-#if __cplusplus >= 201103L
-
 template <typename T1, typename T2>
 Future<tuples::tuple<Future<T1>, Future<T2>>> await(
     const Future<T1>& future1,
@@ -271,57 +239,6 @@ Future<tuples::tuple<Future<T1>, Future<T2>, Future<T3>>> await(
     .then([=] () { return tuples::make_tuple(future1, future2, future3); });
 }
 
-#else // __cplusplus >= 201103L
-
-template <typename T1, typename T2>
-Future<tuples::tuple<Future<T1>, Future<T2>>> await(
-    const Future<T1>& future1,
-    const Future<T2>& future2)
-{
-  Owned<Promise<Nothing>> promise1(new Promise<Nothing>());
-  Owned<Promise<Nothing>> promise2(new Promise<Nothing>());
-
-  future1.onAny(lambda::bind(internal::_await<T1>, lambda::_1, promise1));
-  future2.onAny(lambda::bind(internal::_await<T2>, lambda::_1, promise2));
-
-  std::list<Future<Nothing>> futures;
-  futures.push_back(promise1->future());
-  futures.push_back(promise2->future());
-
-  return await(futures)
-    .then(lambda::bind(
-      internal::__await<T1, T2>,
-      tuples::make_tuple(future1, future2)));
-}
-
-
-template <typename T1, typename T2, typename T3>
-Future<tuples::tuple<Future<T1>, Future<T2>, Future<T3>>> await(
-    const Future<T1>& future1,
-    const Future<T2>& future2,
-    const Future<T3>& future3)
-{
-  Owned<Promise<Nothing>> promise1(new Promise<Nothing>());
-  Owned<Promise<Nothing>> promise2(new Promise<Nothing>());
-  Owned<Promise<Nothing>> promise3(new Promise<Nothing>());
-
-  future1.onAny(lambda::bind(internal::_await<T1>, lambda::_1, promise1));
-  future2.onAny(lambda::bind(internal::_await<T2>, lambda::_1, promise2));
-  future3.onAny(lambda::bind(internal::_await<T3>, lambda::_1, promise3));
-
-  std::list<Future<Nothing>> futures;
-  futures.push_back(promise1->future());
-  futures.push_back(promise2->future());
-  futures.push_back(promise3->future());
-
-  return await(futures)
-    .then(lambda::bind(
-      internal::___await<T1, T2, T3>,
-      tuples::make_tuple(future1, future2, future3)));
-}
-
-#endif // __cplusplus >= 201103L
-
 } // namespace process {
 
 #endif // __PROCESS_COLLECT_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/5ab8ff81/3rdparty/libprocess/include/process/defer.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/defer.hpp b/3rdparty/libprocess/include/process/defer.hpp
index ebe6f2d..7b4dd07 100644
--- a/3rdparty/libprocess/include/process/defer.hpp
+++ b/3rdparty/libprocess/include/process/defer.hpp
@@ -1,10 +1,8 @@
-#if __cplusplus >= 201103L
-#include <process/c++11/defer.hpp>
-#else
 #ifndef __PROCESS_DEFER_HPP__
 #define __PROCESS_DEFER_HPP__
 
-#include <tr1/functional>
+#include <functional>
+#include <memory>
 
 #include <process/deferred.hpp>
 #include <process/dispatch.hpp>
@@ -17,84 +15,68 @@ namespace process {
 // The defer mechanism is very similar to the dispatch mechanism (see
 // dispatch.hpp), however, rather than scheduling the method to get
 // invoked, the defer mechanism returns a 'Deferred' object that when
-// invoked does the underlying dispatch. Similar to dispatch, we
-// provide the C++11 variadic template definitions first, and then use
-// Boost preprocessor macros to provide the actual definitions.
-
+// invoked does the underlying dispatch.
 
 // First, definitions of defer for methods returning void:
-//
-// template <typename T, typename ...P>
-// Deferred<void(void)> void defer(const PID<T>& pid,
-//                                 void (T::*method)(P...),
-//                                 P... p)
-// {
-//   void (*dispatch)(const PID<T>&, void (T::*)(P...), P...) =
-//     &process::template dispatch<T, P...>;
-
-//   return Deferred<void(void)>(
-//       std::tr1::bind(dispatch, pid, method, std::forward<P>(p)...));
-// }
 
 template <typename T>
-_Defer<void(*(PID<T>, void (T::*)(void)))
-       (const PID<T>&, void (T::*)(void))>
-defer(const PID<T>& pid, void (T::*method)(void))
+Deferred<void(void)> defer(
+    const PID<T>& pid,
+    void (T::*method)(void))
 {
-  void (*dispatch)(const PID<T>&, void (T::*)(void)) =
-    &process::template dispatch<T>;
-  return std::tr1::bind(dispatch, pid, method);
+  return Deferred<void(void)>([=] () {
+    dispatch(pid, method);
+  });
 }
 
+
 template <typename T>
-_Defer<void(*(PID<T>, void (T::*)(void)))
-       (const PID<T>&, void (T::*)(void))>
-defer(const Process<T>& process, void (T::*method)(void))
+Deferred<void(void)> defer(
+    const Process<T>& process,
+    void (T::*method)(void))
 {
   return defer(process.self(), method);
 }
 
+
 template <typename T>
-_Defer<void(*(PID<T>, void (T::*)(void)))
-       (const PID<T>&, void (T::*)(void))>
-defer(const Process<T>* process, void (T::*method)(void))
+Deferred<void(void)> defer(
+    const Process<T>* process,
+    void (T::*method)(void))
 {
   return defer(process->self(), method);
 }
 
+
+// Due to a bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933)
+// with variadic templates and lambdas, we still need to do
+// preprocessor expansions. In addition, due to a bug with clang (or
+// libc++) we can't use std::bind with a std::function so we have to
+// explicitely use the std::function<R(P...)>::operator() (see
+// http://stackoverflow.com/questions/20097616/stdbind-to-a-stdfunction-crashes-with-clang).
 #define TEMPLATE(Z, N, DATA)                                            \
   template <typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<void(*(PID<T>,                                                 \
-                void (T::*)(ENUM_PARAMS(N, P)),                         \
-                ENUM_PARAMS(N, A)))                                     \
-         (const PID<T>&,                                                \
-          void (T::*)(ENUM_PARAMS(N, P)),                               \
-          ENUM_PARAMS(N, P))>                                           \
-  defer(const PID<T>& pid,                                              \
-        void (T::*method)(ENUM_PARAMS(N, P)),                           \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
+  auto defer(const PID<T>& pid,                                         \
+             void (T::*method)(ENUM_PARAMS(N, P)),                      \
+             ENUM_BINARY_PARAMS(N, A, a))                               \
+    -> _Deferred<decltype(std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::function<void(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \
   {                                                                     \
-    void (*dispatch)(const PID<T>&,                                     \
-                     void (T::*)(ENUM_PARAMS(N, P)),                    \
-                     ENUM_PARAMS(N, P)) =                               \
-      &process::template dispatch<T, ENUM_PARAMS(N, P), ENUM_PARAMS(N, P)>; \
-    return std::tr1::bind(dispatch, pid, method, ENUM_PARAMS(N, a));    \
+    std::function<void(ENUM_PARAMS(N, P))> f(                           \
+        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
+          dispatch(pid, method, ENUM_PARAMS(N, p));                     \
+        });                                                             \
+    return std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \
   }                                                                     \
                                                                         \
   template <typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<void(*(PID<T>,                                                 \
-                void (T::*)(ENUM_PARAMS(N, P)),                         \
-                ENUM_PARAMS(N, A)))                                     \
-         (const PID<T>&,                                                \
-          void (T::*)(ENUM_PARAMS(N, P)),                               \
-          ENUM_PARAMS(N, P))>                                           \
-  defer(const Process<T>& process,                                      \
-        void (T::*method)(ENUM_PARAMS(N, P)),                           \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
+  auto defer(const Process<T>& process,                                 \
+             void (T::*method)(ENUM_PARAMS(N, P)),                      \
+             ENUM_BINARY_PARAMS(N, A, a))                               \
+    -> decltype(defer(process.self(), method, ENUM_PARAMS(N, a)))       \
   {                                                                     \
     return defer(process.self(), method, ENUM_PARAMS(N, a));            \
   }                                                                     \
@@ -102,15 +84,10 @@ defer(const Process<T>* process, void (T::*method)(void))
   template <typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<void(*(PID<T>,                                                 \
-                void (T::*)(ENUM_PARAMS(N, P)),                         \
-                ENUM_PARAMS(N, A)))                                     \
-         (const PID<T>&,                                                \
-          void (T::*)(ENUM_PARAMS(N, P)),                               \
-          ENUM_PARAMS(N, P))>                                           \
-  defer(const Process<T>* process,                                      \
-        void (T::*method)(ENUM_PARAMS(N, P)),                           \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
+  auto defer(const Process<T>* process,                                 \
+             void (T::*method)(ENUM_PARAMS(N, P)),                      \
+             ENUM_BINARY_PARAMS(N, A, a))                               \
+    -> decltype(defer(process->self(), method, ENUM_PARAMS(N, a)))      \
   {                                                                     \
     return defer(process->self(), method, ENUM_PARAMS(N, a));           \
   }
@@ -120,40 +97,25 @@ defer(const Process<T>* process, void (T::*method)(void))
 
 
 // Next, definitions of defer for methods returning future:
-//
-// template <typename R, typename T, typename ...P>
-// Deferred<Future<R>(void)> void defer(const PID<T>& pid,
-//                                      Future<R> (T::*method)(P...),
-//                                      P... p)
-// {
-//   Future<R> (*dispatch)(const PID<T>&, Future<R> (T::*)(P...), P...) =
-//     &process::template dispatch<R, T, P...>;
-//
-//   return Deferred<Future<R>(void)>(
-//       std::tr1::bind(dispatch, pid, method, std::forward<P>(p)...));
-// }
 
 template <typename R, typename T>
-_Defer<Future<R>(*(PID<T>, Future<R> (T::*)(void)))
-       (const PID<T>&, Future<R> (T::*)(void))>
+Deferred<Future<R>(void)>
 defer(const PID<T>& pid, Future<R> (T::*method)(void))
 {
-  Future<R> (*dispatch)(const PID<T>&, Future<R> (T::*)(void)) =
-    &process::template dispatch<R, T>;
-  return std::tr1::bind(dispatch, pid, method);
+  return Deferred<Future<R>(void)>([=] () {
+    return dispatch(pid, method);
+  });
 }
 
 template <typename R, typename T>
-_Defer<Future<R>(*(PID<T>, Future<R> (T::*)(void)))(
-           const PID<T>&, Future<R> (T::*)(void))>
+Deferred<Future<R>(void)>
 defer(const Process<T>& process, Future<R> (T::*method)(void))
 {
   return defer(process.self(), method);
 }
 
 template <typename R, typename T>
-_Defer<Future<R>(*(PID<T>, Future<R> (T::*)(void)))
-       (const PID<T>&, Future<R> (T::*)(void))>
+Deferred<Future<R>(void)>
 defer(const Process<T>* process, Future<R> (T::*method)(void))
 {
   return defer(process->self(), method);
@@ -164,36 +126,26 @@ defer(const Process<T>* process, Future<R> (T::*method)(void))
             typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<Future<R>(*(PID<T>,                                            \
-                     Future<R> (T::*)(ENUM_PARAMS(N, P)),               \
-                     ENUM_PARAMS(N, A)))                                \
-         (const PID<T>&,                                                \
-          Future<R> (T::*)(ENUM_PARAMS(N, P)),                          \
-          ENUM_PARAMS(N, P))>                                           \
-  defer(const PID<T>& pid,                                              \
-        Future<R> (T::*method)(ENUM_PARAMS(N, P)),                      \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
+  auto defer(const PID<T>& pid,                                         \
+             Future<R> (T::*method)(ENUM_PARAMS(N, P)),                 \
+             ENUM_BINARY_PARAMS(N, A, a))                               \
+    -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \
   {                                                                     \
-    Future<R> (*dispatch)(const PID<T>&,                                \
-                          Future<R> (T::*)(ENUM_PARAMS(N, P)),          \
-                          ENUM_PARAMS(N, P)) =                          \
-      &process::template dispatch<R, T, ENUM_PARAMS(N, P), ENUM_PARAMS(N, P)>; \
-    return std::tr1::bind(dispatch, pid, method, ENUM_PARAMS(N, a));    \
+    std::function<Future<R>(ENUM_PARAMS(N, P))> f(                      \
+        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
+          return dispatch(pid, method, ENUM_PARAMS(N, p));              \
+        });                                                             \
+    return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \
   }                                                                     \
                                                                         \
   template <typename R,                                                 \
             typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<Future<R>(*(PID<T>,                                            \
-                     Future<R> (T::*)(ENUM_PARAMS(N, P)),               \
-                     ENUM_PARAMS(N, A)))                                \
-         (const PID<T>&,                                                \
-          Future<R> (T::*)(ENUM_PARAMS(N, P)),                          \
-          ENUM_PARAMS(N, P))>                                           \
-  defer(const Process<T>& process,                                      \
-        Future<R> (T::*method)(ENUM_PARAMS(N, P)),                      \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
+  auto defer(const Process<T>& process,                                 \
+             Future<R> (T::*method)(ENUM_PARAMS(N, P)),                 \
+             ENUM_BINARY_PARAMS(N, A, a))                               \
+    -> decltype(defer(process.self(), method, ENUM_PARAMS(N, a)))       \
   {                                                                     \
     return defer(process.self(), method, ENUM_PARAMS(N, a));            \
   }                                                                     \
@@ -202,15 +154,10 @@ defer(const Process<T>* process, Future<R> (T::*method)(void))
             typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<Future<R>(*(PID<T>,                                            \
-                     Future<R> (T::*)(ENUM_PARAMS(N, P)),               \
-                     ENUM_PARAMS(N, A)))                                \
-         (const PID<T>&,                                                \
-          Future<R> (T::*)(ENUM_PARAMS(N, P)),                          \
-          ENUM_PARAMS(N, P))>                                           \
-  defer(const Process<T>* process,                                      \
-        Future<R> (T::*method)(ENUM_PARAMS(N, P)),                      \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
+  auto defer(const Process<T>* process,                                 \
+             Future<R> (T::*method)(ENUM_PARAMS(N, P)),                 \
+             ENUM_BINARY_PARAMS(N, A, a))                               \
+    -> decltype(defer(process->self(), method, ENUM_PARAMS(N, a)))      \
   {                                                                     \
     return defer(process->self(), method, ENUM_PARAMS(N, a));           \
   }
@@ -219,41 +166,26 @@ defer(const Process<T>* process, Future<R> (T::*method)(void))
 #undef TEMPLATE
 
 
-// Next, definitions of defer for methods returning a value:
-//
-// template <typename R, typename T, typename ...P>
-// Deferred<Future<R>(void)> void defer(const PID<T>& pid,
-//                                      R (T::*method)(P...),
-//                                      P... p)
-// {
-//   Future<R> (*dispatch)(const PID<T>&, R (T::*)(P...), P...) =
-//     &process::template dispatch<R, T, P...>;
-//
-//   return Deferred<Future<R>(void)>(
-//       std::tr1::bind(dispatch, pid, method, std::forward<P>(p)...));
-// }
+// Finaly, definitions of defer for methods returning a value:
 
 template <typename R, typename T>
-_Defer<Future<R>(*(PID<T>, R (T::*)(void)))
-       (const PID<T>&, R (T::*)(void))>
+Deferred<Future<R>(void)>
 defer(const PID<T>& pid, R (T::*method)(void))
 {
-  Future<R> (*dispatch)(const PID<T>&, R (T::*)(void)) =
-    &process::template dispatch<R, T>;
-  return std::tr1::bind(dispatch, pid, method);
+  return Deferred<Future<R>(void)>([=] () {
+    return dispatch(pid, method);
+  });
 }
 
 template <typename R, typename T>
-_Defer<Future<R>(*(PID<T>, R (T::*)(void)))
-       (const PID<T>&, R (T::*)(void))>
+Deferred<Future<R>(void)>
 defer(const Process<T>& process, R (T::*method)(void))
 {
   return defer(process.self(), method);
 }
 
 template <typename R, typename T>
-_Defer<Future<R>(*(PID<T>, R (T::*)(void)))
-       (const PID<T>&, R (T::*)(void))>
+Deferred<Future<R>(void)>
 defer(const Process<T>* process, R (T::*method)(void))
 {
   return defer(process->self(), method);
@@ -264,36 +196,27 @@ defer(const Process<T>* process, R (T::*method)(void))
             typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<Future<R>(*(PID<T>,                                            \
-                     R (T::*)(ENUM_PARAMS(N, P)),                       \
-                     ENUM_PARAMS(N, A)))                                \
-         (const PID<T>&,                                                \
-          R (T::*)(ENUM_PARAMS(N, P)),                                  \
-          ENUM_PARAMS(N, P))>                                           \
-  defer(const PID<T>& pid,                                              \
-        R (T::*method)(ENUM_PARAMS(N, P)),                              \
-        ENUM_BINARY_PARAMS(N, A, a))                                    \
+  auto defer(const PID<T>& pid,                                         \
+             R (T::*method)(ENUM_PARAMS(N, P)),                         \
+             ENUM_BINARY_PARAMS(N, A, a))                               \
+    -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \
   {                                                                     \
-    Future<R> (*dispatch)(const PID<T>&,                                \
-                          R (T::*)(ENUM_PARAMS(N, P)),                  \
-                          ENUM_PARAMS(N, P)) =                          \
-      &process::template dispatch<R, T, ENUM_PARAMS(N, P), ENUM_PARAMS(N, P)>; \
-    return std::tr1::bind(dispatch, pid, method, ENUM_PARAMS(N, a));    \
+    std::function<Future<R>(ENUM_PARAMS(N, P))> f(                      \
+        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
+          return dispatch(pid, method, ENUM_PARAMS(N, p));              \
+        });                                                             \
+    return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \
   }                                                                     \
                                                                         \
   template <typename R,                                                 \
             typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<Future<R>(*(PID<T>,                                            \
-                     R (T::*)(ENUM_PARAMS(N, P)),                       \
-                     ENUM_PARAMS(N, A)))                                \
-         (const PID<T>&,                                                \
-          R (T::*)(ENUM_PARAMS(N, P)),                                  \
-          ENUM_PARAMS(N, P))>                                           \
+  auto                                                                  \
   defer(const Process<T>& process,                                      \
         R (T::*method)(ENUM_PARAMS(N, P)),                              \
         ENUM_BINARY_PARAMS(N, A, a))                                    \
+    -> decltype(defer(process.self(), method, ENUM_PARAMS(N, a)))       \
   {                                                                     \
     return defer(process.self(), method, ENUM_PARAMS(N, a));            \
   }                                                                     \
@@ -302,15 +225,11 @@ defer(const Process<T>* process, R (T::*method)(void))
             typename T,                                                 \
             ENUM_PARAMS(N, typename P),                                 \
             ENUM_PARAMS(N, typename A)>                                 \
-  _Defer<Future<R>(*(PID<T>,                                            \
-                     R (T::*)(ENUM_PARAMS(N, P)),                       \
-                     ENUM_PARAMS(N, A)))                                \
-         (const PID<T>&,                                                \
-          R (T::*)(ENUM_PARAMS(N, P)),                                  \
-          ENUM_PARAMS(N, P))>                                           \
+  auto                                                                  \
   defer(const Process<T>* process,                                      \
         R (T::*method)(ENUM_PARAMS(N, P)),                              \
         ENUM_BINARY_PARAMS(N, A, a))                                    \
+    -> decltype(defer(process->self(), method, ENUM_PARAMS(N, a)))      \
   {                                                                     \
     return defer(process->self(), method, ENUM_PARAMS(N, a));           \
   }
@@ -319,195 +238,25 @@ defer(const Process<T>* process, R (T::*method)(void))
 #undef TEMPLATE
 
 
-namespace internal {
-
-inline void invoker(
-    ProcessBase* _,
-    const std::tr1::function<void(void)>& f)
-{
-  f();
-}
-
-inline void dispatcher(
-    const UPID& pid,
-    const std::tr1::function<void(void)>& f)
-{
-  std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > invoker(
-      new std::tr1::function<void(ProcessBase*)>(
-          std::tr1::bind(&internal::invoker,
-                         std::tr1::placeholders::_1,
-                         f)));
-
-  internal::dispatch(pid, invoker);
-}
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <ENUM_PARAMS(N, typename A)>                                 \
-  void CAT(vinvoker, N)(                                                \
-      ProcessBase* _,                                                   \
-      const std::tr1::function<void(ENUM_PARAMS(N, A))>& f,             \
-      ENUM_BINARY_PARAMS(N, A, a))                                      \
-  {                                                                     \
-    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(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(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.
-#undef TEMPLATE
-
-
-  // We can't easily use 'std::tr1::_Placeholder<X>' when doing macro
-  // expansion via ENUM_BINARY_PARAMS because compilers don't like it
-  // when you try and concatenate '<' 'N' '>'. Thus, we typedef them.
-#define TEMPLATE(Z, N, DATA)                            \
-  typedef std::tr1::_Placeholder<INC(N)> _ ## N;
-
-  REPEAT(10, TEMPLATE, _)
-#undef TEMPLATE
-
-} // namespace internal {
-
+// Now we define defer calls for functors (with and without a PID):
 
-// Now we define defer calls for functions and bind statements.
-inline Deferred<void(void)> defer(
-    const UPID& pid,
-    const std::tr1::function<void(void)>& f)
+template <typename F>
+_Deferred<F> defer(const UPID& pid, F&& f)
 {
-  return std::tr1::function<void(void)>(
-      std::tr1::bind(&internal::dispatcher,
-                     pid,
-                     f));
+  return _Deferred<F>(pid, std::forward<F>(f));
 }
 
 
-// Now we define defer calls for functions and bind statements.
-inline Deferred<void(void)> defer(const std::tr1::function<void(void)>& f)
+template <typename F>
+_Deferred<F> defer(F&& f)
 {
   if (__process__ != NULL) {
-    // In C++11:
-    //   const UPID pid = __process__->self();
-    //   return []() {
-    //     internal::dispatch(pid, [](ProcessBase* _) { f(); });
-    //   }
-    return std::tr1::function<void(void)>(
-          std::tr1::bind(&internal::dispatcher,
-                         __process__->self(),
-                         f));
+    return defer(__process__->self(), std::forward<F>(f));
   }
 
-  return __executor__->defer(f);
+  return __executor__->defer(std::forward<F>(f));
 }
 
-
-#define TEMPLATE(Z, N, DATA)                                            \
-  template <ENUM_PARAMS(N, typename A)>                                 \
-  Deferred<void(ENUM_PARAMS(N, A))> defer(                              \
-      const UPID& pid,                                                  \
-      const std::tr1::function<void(ENUM_PARAMS(N, A))>& f)             \
-  {                                                                     \
-    return std::tr1::function<void(ENUM_PARAMS(N, A))>(                 \
-        std::tr1::bind(&internal::CAT(vdispatcher, N)<ENUM_PARAMS(N, A)>, \
-                       pid,                                             \
-                       f,                                               \
-                       ENUM_BINARY_PARAMS(N, internal::_, () INTERCEPT))); \
-  }                                                                     \
-                                                                        \
-  template <ENUM_PARAMS(N, typename A)>                                 \
-  Deferred<void(ENUM_PARAMS(N, A))> defer(                              \
-      const std::tr1::function<void(ENUM_PARAMS(N, A))>& f)             \
-  {                                                                     \
-    if (__process__ != NULL) {                                          \
-      return std::tr1::function<void(ENUM_PARAMS(N, A))>(               \
-          std::tr1::bind(&internal::CAT(vdispatcher, N)<ENUM_PARAMS(N, A)>, \
-                         __process__->self(),                           \
-                         f,                                             \
-                         ENUM_BINARY_PARAMS(N, internal::_, () INTERCEPT))); \
-    }                                                                   \
-                                                                        \
-    return __executor__->defer(f);                                      \
-  }                                                                     \
-                                                                        \
-  template <typename R, ENUM_PARAMS(N, typename A)>                     \
-  Deferred<Future<R>(ENUM_PARAMS(N, A))> defer(                         \
-      const UPID& pid,                                                  \
-      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)<R, ENUM_PARAMS(N, A)>, \
-                       pid,                                             \
-                       f,                                               \
-                       ENUM_BINARY_PARAMS(N, internal::_, () INTERCEPT))); \
-  }                                                                     \
-                                                                        \
-  template <typename R, ENUM_PARAMS(N, typename A)>                     \
-  Deferred<Future<R>(ENUM_PARAMS(N, A))> defer(                         \
-      const std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>& f)        \
-  {                                                                     \
-    if (__process__ != NULL) {                                          \
-      return std::tr1::function<Future<R>(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))); \
-    }                                                                   \
-                                                                        \
-    return __executor__->defer(f);                                      \
-  }
-
-  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
-#undef TEMPLATE
-
 } // namespace process {
 
 #endif // __PROCESS_DEFER_HPP__
-#endif // __cplusplus >= 201103L