Added overloads to 'process::defer()' to dispatch lambda function
to a specific pid.


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

Branch: refs/heads/master
Commit: 94b9439371db9e8e7e3a102fdbe73b80a1da6a8b
Parents: 52cf9b3
Author: Benjamin Hindman <[email protected]>
Authored: Fri Aug 8 16:51:23 2014 -0700
Committer: Vinod Kone <[email protected]>
Committed: Fri Aug 8 17:03:17 2014 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/defer.hpp   | 36 ++++++++++++++++++++
 .../libprocess/include/process/deferred.hpp     | 17 ++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/94b94393/3rdparty/libprocess/include/process/defer.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/defer.hpp 
b/3rdparty/libprocess/include/process/defer.hpp
index dc2ec3b..dce7f3b 100644
--- a/3rdparty/libprocess/include/process/defer.hpp
+++ b/3rdparty/libprocess/include/process/defer.hpp
@@ -384,6 +384,18 @@ inline void dispatcher(
 
 
 // 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)
+{
+  return std::tr1::function<void(void)>(
+      std::tr1::bind(&internal::dispatcher,
+                     pid,
+                     f));
+}
+
+
+// Now we define defer calls for functions and bind statements.
 inline Deferred<void(void)> defer(const std::tr1::function<void(void)>& f)
 {
   if (__process__ != NULL) {
@@ -405,6 +417,18 @@ inline Deferred<void(void)> defer(const 
std::tr1::function<void(void)>& 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(dispatcher, 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) {                                          \
@@ -420,6 +444,18 @@ inline Deferred<void(void)> defer(const 
std::tr1::function<void(void)>& 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)<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) {                                          \

http://git-wip-us.apache.org/repos/asf/mesos/blob/94b94393/3rdparty/libprocess/include/process/deferred.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/deferred.hpp 
b/3rdparty/libprocess/include/process/deferred.hpp
index 0552fb5..8bdc692 100644
--- a/3rdparty/libprocess/include/process/deferred.hpp
+++ b/3rdparty/libprocess/include/process/deferred.hpp
@@ -31,15 +31,30 @@ private:
 
   template <typename _F> friend struct _Defer;
 
-  friend Deferred<void(void)> defer(const std::tr1::function<void(void)>& f);
+  friend Deferred<void(void)> defer(
+      const UPID& pid,
+      const std::tr1::function<void(void)>& f);
+
+  friend Deferred<void(void)> defer(
+      const std::tr1::function<void(void)>& f);
 
 #define TEMPLATE(Z, N, DATA)                                            \
   template <ENUM_PARAMS(N, typename A)>                                 \
   friend Deferred<void(ENUM_PARAMS(N, A))> defer(                       \
+      const UPID& pid,                                                  \
+      const std::tr1::function<void(ENUM_PARAMS(N, A))>& f);            \
+                                                                        \
+  template <ENUM_PARAMS(N, typename A)>                                 \
+  friend Deferred<void(ENUM_PARAMS(N, A))> defer(                       \
       const std::tr1::function<void(ENUM_PARAMS(N, A))>& f);            \
                                                                         \
   template <typename R, ENUM_PARAMS(N, typename A)>                     \
   friend Deferred<Future<R>(ENUM_PARAMS(N, A))> defer(                  \
+      const UPID& pid,                                                  \
+      const std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>& f);       \
+                                                                        \
+  template <typename R, ENUM_PARAMS(N, typename A)>                     \
+  friend Deferred<Future<R>(ENUM_PARAMS(N, A))> defer(                  \
       const std::tr1::function<Future<R>(ENUM_PARAMS(N, A))>& f);
 
   REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.

Reply via email to