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 2012/05/01 01:22:46 UTC

svn commit: r1332468 - in /incubator/mesos/trunk: src/log/ src/master/ src/sched/ src/slave/ src/zookeeper/ third_party/libprocess/ third_party/libprocess/include/process/ third_party/libprocess/src/

Author: benh
Date: Mon Apr 30 23:22:45 2012
New Revision: 1332468

URL: http://svn.apache.org/viewvc?rev=1332468&view=rev
Log:
Updated ZooKeeperNetwork to use process::collect rather than be blocking.

Added:
    incubator/mesos/trunk/third_party/libprocess/include/process/delay.hpp
      - copied, changed from r1332467, incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp
Modified:
    incubator/mesos/trunk/src/log/network.hpp
    incubator/mesos/trunk/src/master/frameworks_manager.cpp
    incubator/mesos/trunk/src/master/master.cpp
    incubator/mesos/trunk/src/sched/sched.cpp
    incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp
    incubator/mesos/trunk/src/slave/reaper.cpp
    incubator/mesos/trunk/src/slave/slave.cpp
    incubator/mesos/trunk/src/zookeeper/group.cpp
    incubator/mesos/trunk/third_party/libprocess/Makefile.am
    incubator/mesos/trunk/third_party/libprocess/include/process/collect.hpp
    incubator/mesos/trunk/third_party/libprocess/include/process/defer.hpp
    incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp
    incubator/mesos/trunk/third_party/libprocess/src/process.cpp
    incubator/mesos/trunk/third_party/libprocess/src/tests.cpp

Modified: incubator/mesos/trunk/src/log/network.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/log/network.hpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/log/network.hpp (original)
+++ incubator/mesos/trunk/src/log/network.hpp Mon Apr 30 23:22:45 2012
@@ -25,7 +25,7 @@
 #include <set>
 #include <string>
 
-#include <process/deferred.hpp>
+#include <process/collect.hpp>
 #include <process/executor.hpp>
 #include <process/protobuf.hpp>
 #include <process/timeout.hpp>
@@ -89,22 +89,21 @@ public:
   ZooKeeperNetwork(zookeeper::Group* group);
 
 private:
-  // Helper that sets up a watch on the group.
-  void watch(const std::set<zookeeper::Group::Membership>& memberships =
-             std::set<zookeeper::Group::Membership>());
+  typedef ZooKeeperNetwork This;
 
-  // Invoked when the group has updated.
-  void ready(const std::set<zookeeper::Group::Membership>& memberships);
+  // Helper that sets up a watch on the group.
+  void watch(const std::set<zookeeper::Group::Membership>& expected);
 
-  // Invoked if watching the group fails.
-  void failed(const std::string& message) const;
+  // Invoked when the group memberships have changed.
+  void watched();
 
-  // Invoked if we were unable to watch the group.
-  void discarded() const;
+  // Invoked when group members data has been collected.
+  void collected();
 
   zookeeper::Group* group;
-
   process::Executor executor;
+  process::Future<std::set<zookeeper::Group::Membership> > memberships;
+  process::Future<std::list<std::string> > infos;
 };
 
 
@@ -243,60 +242,68 @@ void Network::broadcast(
   process::dispatch(process, broadcast, m, filter);
 }
 
+
 inline ZooKeeperNetwork::ZooKeeperNetwork(zookeeper::Group* _group)
   : group(_group)
 {
-  watch();
+  watch(std::set<zookeeper::Group::Membership>());
 }
 
 
 inline void ZooKeeperNetwork::watch(
-    const std::set<zookeeper::Group::Membership>& memberships)
+    const std::set<zookeeper::Group::Membership>& expected)
+{
+  memberships = group->watch(expected);
+  memberships.onAny(executor.defer(lambda::bind(&This::watched, this)));
+}
+
+
+inline void ZooKeeperNetwork::watched()
 {
-  process::deferred<void(const std::set<zookeeper::Group::Membership>&)> ready =
-    executor.defer(lambda::bind(&ZooKeeperNetwork::ready, this, lambda::_1));
+  if (memberships.isFailed()) {
+    // We can't do much here, we could try creating another Group but
+    // that might just continue indifinitely, so we fail early
+    // instead. Note that Group handles all retryable/recoverable
+    // ZooKeeper errors internally.
+    LOG(FATAL) << "Failed to watch ZooKeeper group: " << memberships.failure();
+  }
 
-  process::deferred<void(const std::string&)> failed =
-    executor.defer(lambda::bind(&ZooKeeperNetwork::failed, this, lambda::_1));
+  CHECK(memberships.isReady()); // Not expecting Group to discard futures.
+
+  LOG(INFO) << "ZooKeeper group memberships changed";
 
-  process::deferred<void(void)> discarded =
-    executor.defer(lambda::bind(&ZooKeeperNetwork::discarded, this));
+  // Get data for each membership in order to convert them to PIDs.
+  std::list<process::Future<std::string> > futures;
 
-  group->watch(memberships)
-    .onReady(ready)
-    .onFailed(failed)
-    .onDiscarded(discarded);
+  foreach (const zookeeper::Group::Membership& membership, memberships.get()) {
+    futures.push_back(group->info(membership));
+  }
+
+  infos = process::collect(futures, process::Timeout(5.0));
+  infos.onAny(executor.defer(lambda::bind(&This::collected, this)));
 }
 
 
-inline void ZooKeeperNetwork::ready(
-    const std::set<zookeeper::Group::Membership>& memberships)
+inline void ZooKeeperNetwork::collected()
 {
-  LOG(INFO) << "ZooKeeper group memberships changed";
+  if (infos.isFailed()) {
+    LOG(WARNING) << "Failed to get data for ZooKeeper group members: "
+                 << infos.failure();
 
-  // Get infos for each membership in order to convert them to PIDs.
-  std::set<process::Future<std::string> > futures;
-
-  foreach (const zookeeper::Group::Membership& membership, memberships) {
-    futures.insert(group->info(membership));
+    // Try again later assuming empty group. Note that this does not
+    // remove any of the current group members.
+    watch(std::set<zookeeper::Group::Membership>());
+    return;
   }
 
-  std::set<process::UPID> pids;
+  CHECK(infos.isReady()); // Not expecting collect to discard futures.
 
-  process::Timeout timeout = 5.0;
+  std::set<process::UPID> pids;
 
-  while (!futures.empty()) {
-    process::Future<process::Future<std::string> > future = select(futures);
-    if (future.await(timeout.remaining())) {
-      CHECK(future.get().isReady());
-      process::UPID pid(future.get().get());
-      CHECK(pid) << "Failed to parse '" << future.get().get() << "'";
-      pids.insert(pid);
-      futures.erase(future.get());
-    } else {
-      watch(); // Try again later assuming empty group.
-      return;
-    }
+  foreach (const std::string& info, infos.get()) {
+    process::UPID pid(info);
+    CHECK(pid) << "Failed to parse '" << info << "'";
+    pids.insert(pid);
   }
 
   LOG(INFO) << "ZooKeeper group PIDs: "
@@ -304,19 +311,7 @@ inline void ZooKeeperNetwork::ready(
 
   set(pids); // Update the network.
 
-  watch(memberships);
-}
-
-
-inline void ZooKeeperNetwork::failed(const std::string& message) const
-{
-  LOG(FATAL) << "Failed to watch ZooKeeper group: "<< message;
-}
-
-
-inline void ZooKeeperNetwork::discarded() const
-{
-  LOG(FATAL) << "Unexpected discarded future while watching ZooKeeper group";
+  watch(memberships.get());
 }
 
 #endif // __NETWORK_HPP__

Modified: incubator/mesos/trunk/src/master/frameworks_manager.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/frameworks_manager.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/frameworks_manager.cpp (original)
+++ incubator/mesos/trunk/src/master/frameworks_manager.cpp Mon Apr 30 23:22:45 2012
@@ -16,13 +16,13 @@
  * limitations under the License.
  */
 
-#include <glog/logging.h>
-
-#include <process/timer.hpp>
+#include <process/delay.hpp>
+#include <process/dispatch.hpp>
 
 #include "master/frameworks_manager.hpp"
 
 #include "common/foreach.hpp"
+#include "common/logging.hpp"
 #include "common/type_utils.hpp"
 
 using std::map;

Modified: incubator/mesos/trunk/src/master/master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/master.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/master.cpp (original)
+++ incubator/mesos/trunk/src/master/master.cpp Mon Apr 30 23:22:45 2012
@@ -21,13 +21,12 @@
 #include <list>
 #include <sstream>
 
-#include <glog/logging.h>
-
+#include <process/delay.hpp>
 #include <process/run.hpp>
-#include <process/timer.hpp>
 
 #include "common/build.hpp"
 #include "common/date_utils.hpp"
+#include "common/logging.hpp"
 #include "common/utils.hpp"
 #include "common/uuid.hpp"
 

Modified: incubator/mesos/trunk/src/sched/sched.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/sched/sched.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/sched/sched.cpp (original)
+++ incubator/mesos/trunk/src/sched/sched.cpp Mon Apr 30 23:22:45 2012
@@ -32,11 +32,11 @@
 
 #include <mesos/scheduler.hpp>
 
+#include <process/delay.hpp>
 #include <process/dispatch.hpp>
 #include <process/id.hpp>
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
-#include <process/timer.hpp>
 
 #include "configurator/configuration.hpp"
 

Modified: incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp Mon Apr 30 23:22:45 2012
@@ -21,8 +21,7 @@
 #include <map>
 
 #include <process/dispatch.hpp>
-
-#include "lxc_isolation_module.hpp"
+#include <process/id.hpp>
 
 #include "common/foreach.hpp"
 #include "common/type_utils.hpp"
@@ -31,6 +30,8 @@
 
 #include "launcher/launcher.hpp"
 
+#include "slave/lxc_isolation_module.hpp"
+
 using namespace mesos;
 using namespace mesos::internal;
 using namespace mesos::internal::slave;

Modified: incubator/mesos/trunk/src/slave/reaper.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/reaper.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/reaper.cpp (original)
+++ incubator/mesos/trunk/src/slave/reaper.cpp Mon Apr 30 23:22:45 2012
@@ -19,9 +19,9 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include <process/delay.hpp>
 #include <process/dispatch.hpp>
 #include <process/id.hpp>
-#include <process/timer.hpp>
 
 #include "common/foreach.hpp"
 

Modified: incubator/mesos/trunk/src/slave/slave.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.cpp (original)
+++ incubator/mesos/trunk/src/slave/slave.cpp Mon Apr 30 23:22:45 2012
@@ -22,8 +22,9 @@
 #include <algorithm>
 #include <iomanip>
 
+#include <process/delay.hpp>
+#include <process/dispatch.hpp>
 #include <process/id.hpp>
-#include <process/timer.hpp>
 
 #include "common/build.hpp"
 #include "common/option.hpp"

Modified: incubator/mesos/trunk/src/zookeeper/group.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/zookeeper/group.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/src/zookeeper/group.cpp (original)
+++ incubator/mesos/trunk/src/zookeeper/group.cpp Mon Apr 30 23:22:45 2012
@@ -4,8 +4,9 @@
 #include <utility>
 #include <vector>
 
+#include <process/delay.hpp>
+#include <process/dispatch.hpp>
 #include <process/process.hpp>
-#include <process/timer.hpp>
 
 #include "common/result.hpp"
 #include "common/strings.hpp"

Modified: incubator/mesos/trunk/third_party/libprocess/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/Makefile.am?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/Makefile.am (original)
+++ incubator/mesos/trunk/third_party/libprocess/Makefile.am Mon Apr 30 23:22:45 2012
@@ -39,6 +39,7 @@ libprocess_la_LIBADD = $(GLOG)/libglog.l
 # Headers.
 libprocess_la_SOURCES += $(top_srcdir)/include/process/clock.hpp	\
 	$(top_srcdir)/include/process/collect.hpp			\
+	$(top_srcdir)/include/process/delay.hpp				\
 	$(top_srcdir)/include/process/defer.hpp				\
 	$(top_srcdir)/include/process/deferred.hpp			\
 	$(top_srcdir)/include/process/dispatch.hpp			\

Modified: incubator/mesos/trunk/third_party/libprocess/include/process/collect.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/collect.hpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/collect.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/collect.hpp Mon Apr 30 23:22:45 2012
@@ -6,8 +6,11 @@
 #include <list>
 
 #include <process/defer.hpp>
+#include <process/delay.hpp>
 #include <process/future.hpp>
+#include <process/option.hpp>
 #include <process/process.hpp>
+#include <process/timeout.hpp>
 
 namespace process {
 
@@ -16,7 +19,9 @@ namespace process {
 // be a failure. Likewise, if any future fails than the result future
 // will be a failure.
 template <typename T>
-Future<std::list<T> > collect(std::list<Future<T> >& futures);
+Future<std::list<T> > collect(
+    std::list<Future<T> >& futures,
+    const Option<Timeout>& timeout = Option<Timeout>::none());
 
 
 namespace internal {
@@ -27,8 +32,11 @@ class CollectProcess : public Process<Co
 public:
   CollectProcess(
       const std::list<Future<T> >& _futures,
+      const Option<Timeout>& _timeout,
       Promise<std::list<T> >* _promise)
-    : futures(_futures), promise(_promise) {}
+    : futures(_futures),
+      timeout(_timeout),
+      promise(_promise) {}
 
   virtual ~CollectProcess()
   {
@@ -40,7 +48,12 @@ public:
     // Stop this nonsense if nobody cares.
     promise->future().onDiscarded(defer(this, &CollectProcess::discarded));
 
-    typename std::list<Future<T> >::iterator iterator;
+    // Only wait as long as requested.
+    if (timeout.isSome()) {
+      delay(timeout.get().remaining(), this, &CollectProcess::timedout);
+    }
+
+    typename std::list<Future<T> >::const_iterator iterator;
     for (iterator = futures.begin(); iterator != futures.end(); ++iterator) {
       const Future<T>& future = *iterator;
       future.onAny(defer(this, &CollectProcess::waited, future));
@@ -53,6 +66,12 @@ private:
     terminate(this);
   }
 
+  void timedout()
+  {
+    promise->fail("Collect failed: timed out");
+    terminate(this);
+  }
+
   void waited(const Future<T>& future)
   {
     if (future.isFailed()) {
@@ -69,7 +88,8 @@ private:
     }
   }
 
-  std::list<Future<T> > futures;
+  const std::list<Future<T> > futures;
+  const Option<Timeout> timeout;
   Promise<std::list<T> >* promise;
   std::list<T> values;
 };
@@ -78,10 +98,12 @@ private:
 
 
 template <typename T>
-inline Future<std::list<T> > collect(std::list<Future<T> >& futures)
+inline Future<std::list<T> > collect(
+    std::list<Future<T> >& futures,
+    const Option<Timeout>& timeout)
 {
   Promise<std::list<T> >* promise = new Promise<std::list<T> >();
-  spawn(new internal::CollectProcess<T>(futures, promise), true);
+  spawn(new internal::CollectProcess<T>(futures, timeout, promise), true);
   return promise->future();
 }
 

Modified: incubator/mesos/trunk/third_party/libprocess/include/process/defer.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/defer.hpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/defer.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/defer.hpp Mon Apr 30 23:22:45 2012
@@ -1,6 +1,8 @@
 #ifndef __PROCESS_DEFER_HPP__
 #define __PROCESS_DEFER_HPP__
 
+#include <tr1/functional>
+
 #include <process/deferred.hpp>
 #include <process/dispatch.hpp>
 

Copied: incubator/mesos/trunk/third_party/libprocess/include/process/delay.hpp (from r1332467, incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/delay.hpp?p2=incubator/mesos/trunk/third_party/libprocess/include/process/delay.hpp&p1=incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp&r1=1332467&r2=1332468&rev=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/delay.hpp Mon Apr 30 23:22:45 2012
@@ -1,78 +1,17 @@
-#ifndef __PROCESS_TIMER_HPP__
-#define __PROCESS_TIMER_HPP__
+#ifndef __PROCESS_DELAY_HPP__
+#define __PROCESS_DELAY_HPP__
 
-#include <stdlib.h> // For abort.
+#include <tr1/functional>
 
 #include <process/dispatch.hpp>
-#include <process/process.hpp>
-#include <process/timeout.hpp>
+#include <process/timer.hpp>
 
 namespace process {
 
-// Timer support! Note that we don't store a pointer to the issuing
-// process (if there is one) because we can't dereference it because
-// it might no longer be valid. (Instead we can use the PID to check
-// if the issuing process is still valid and get a refernce to it).
-
-class Timer; // Forward declaration.
-
-namespace timers {
-
-Timer create(double secs, const std::tr1::function<void(void)>& thunk);
-bool cancel(const Timer& timer);
-
-} // namespace timers {
-
-
-class Timer
-{
-public:
-  Timer() : id(0), t(0), pid(process::UPID()), thunk(&abort) {}
-
-  bool operator == (const Timer& that) const
-  {
-    return id == that.id;
-  }
-
-  // Invokes this timer's thunk.
-  void operator () () const
-  {
-    thunk();
-  }
-
-  // Returns the timeout associated with this timer.
-  Timeout timeout() const
-  {
-    return t;
-  }
-
-  // Returns the PID of the running process when this timer was
-  // created (via timers::create) or an empty PID if no process was
-  // running when this timer was created.
-  process::UPID creator() const
-  {
-    return pid;
-  }
-
-private:
-  friend Timer timers::create(double, const std::tr1::function<void(void)>&);
-
-  Timer(long _id,
-        const Timeout& _t,
-        const process::UPID& _pid,
-        const std::tr1::function<void(void)>& _thunk)
-    : id(_id), t(_t), pid(_pid), thunk(_thunk)
-  {}
-
-  uint64_t id; // Used for equality.
-  Timeout t;
-  process::UPID pid; // Running process when this timer was created.
-  std::tr1::function<void(void)> thunk;
-};
-
-
-// Delay a dispatch to a process. Returns a timer which can attempted
-// to be canceled if desired (but might be firing concurrently).
+// 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(double secs,
@@ -96,6 +35,24 @@ Timer delay(double secs,
 }
 
 
+template <typename T>
+Timer delay(double secs,
+            const Process<T>& process,
+            void (T::*method)())
+{
+  return delay(secs, process.self(), method);
+}
+
+
+template <typename T>
+Timer delay(double secs,
+            const Process<T>* process,
+            void (T::*method)())
+{
+  return delay(secs, process->self(), method);
+}
+
+
 template <typename T, typename P1, typename A1>
 Timer delay(double secs,
             const PID<T>& pid,
@@ -119,6 +76,26 @@ Timer delay(double secs,
 }
 
 
+template <typename T, typename P1, typename A1>
+Timer delay(double secs,
+            const Process<T>& process,
+            void (T::*method)(P1),
+            A1 a1)
+{
+  return delay(secs, process.self(), method, a1);
+}
+
+
+template <typename T, typename P1, typename A1>
+Timer delay(double secs,
+            const Process<T>* process,
+            void (T::*method)(P1),
+            A1 a1)
+{
+  return delay(secs, process->self(), method, a1);
+}
+
+
 template <typename T,
           typename P1, typename P2,
           typename A1, typename A2>
@@ -145,6 +122,30 @@ Timer delay(double secs,
 
 
 template <typename T,
+          typename P1, typename P2,
+          typename A1, typename A2>
+Timer delay(double secs,
+            const Process<T>& process,
+            void (T::*method)(P1, P2),
+            A1 a1, A2 a2)
+{
+  return delay(secs, process.self(), method, a1, a2);
+}
+
+
+template <typename T,
+          typename P1, typename P2,
+          typename A1, typename A2>
+Timer delay(double secs,
+            const Process<T>* process,
+            void (T::*method)(P1, P2),
+            A1 a1, A2 a2)
+{
+  return delay(secs, process->self(), method, a1, a2);
+}
+
+
+template <typename T,
           typename P1, typename P2, typename P3,
           typename A1, typename A2, typename A3>
 Timer delay(double secs,
@@ -168,6 +169,30 @@ Timer delay(double secs,
   return timers::create(secs, dispatch);
 }
 
+
+template <typename T,
+          typename P1, typename P2, typename P3,
+          typename A1, typename A2, typename A3>
+Timer delay(double secs,
+            const Process<T>& process,
+            void (T::*method)(P1, P2, P3),
+            A1 a1, A2 a2, A3 a3)
+{
+  return delay(secs, process.self(), method, a1, a2, a3);
+}
+
+
+template <typename T,
+          typename P1, typename P2, typename P3,
+          typename A1, typename A2, typename A3>
+Timer delay(double secs,
+            const Process<T>* process,
+            void (T::*method)(P1, P2, P3),
+            A1 a1, A2 a2, A3 a3)
+{
+  return delay(secs, process->self(), method, a1, a2, a3);
+}
+
 } // namespace process {
 
-#endif // __PROCESS_TIMER_HPP__
+#endif // __PROCESS_DELAY_HPP__

Modified: incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp Mon Apr 30 23:22:45 2012
@@ -3,8 +3,8 @@
 
 #include <stdlib.h> // For abort.
 
-#include <process/dispatch.hpp>
-#include <process/process.hpp>
+#include <tr1/functional>
+
 #include <process/timeout.hpp>
 
 namespace process {
@@ -70,104 +70,6 @@ private:
   std::tr1::function<void(void)> thunk;
 };
 
-
-// Delay a dispatch to a process. Returns a timer which can attempted
-// to be canceled if desired (but might be firing concurrently).
-
-template <typename T>
-Timer delay(double secs,
-            const PID<T>& pid,
-            void (T::*method)())
-{
-  std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk(
-      new std::tr1::function<void(T*)>(
-          std::tr1::bind(method, std::tr1::placeholders::_1)));
-
-  std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-      new std::tr1::function<void(ProcessBase*)>(
-          std::tr1::bind(&internal::vdispatcher<T>,
-                         std::tr1::placeholders::_1,
-                         thunk)));
-
-  std::tr1::function<void(void)> dispatch =
-    std::tr1::bind(internal::dispatch, pid, dispatcher);
-
-  return timers::create(secs, dispatch);
-}
-
-
-template <typename T, typename P1, typename A1>
-Timer delay(double secs,
-            const PID<T>& pid,
-            void (T::*method)(P1),
-            A1 a1)
-{
-  std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk(
-      new std::tr1::function<void(T*)>(
-          std::tr1::bind(method, std::tr1::placeholders::_1, a1)));
-
-  std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-      new std::tr1::function<void(ProcessBase*)>(
-          std::tr1::bind(&internal::vdispatcher<T>,
-                         std::tr1::placeholders::_1,
-                         thunk)));
-
-  std::tr1::function<void(void)> dispatch =
-    std::tr1::bind(internal::dispatch, pid, dispatcher);
-
-  return timers::create(secs, dispatch);
-}
-
-
-template <typename T,
-          typename P1, typename P2,
-          typename A1, typename A2>
-Timer delay(double secs,
-            const PID<T>& pid,
-            void (T::*method)(P1, P2),
-            A1 a1, A2 a2)
-{
-  std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk(
-      new std::tr1::function<void(T*)>(
-          std::tr1::bind(method, std::tr1::placeholders::_1, a1, a2)));
-
-  std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-      new std::tr1::function<void(ProcessBase*)>(
-          std::tr1::bind(&internal::vdispatcher<T>,
-                         std::tr1::placeholders::_1,
-                         thunk)));
-
-  std::tr1::function<void(void)> dispatch =
-    std::tr1::bind(internal::dispatch, pid, dispatcher);
-
-  return timers::create(secs, dispatch);
-}
-
-
-template <typename T,
-          typename P1, typename P2, typename P3,
-          typename A1, typename A2, typename A3>
-Timer delay(double secs,
-            const PID<T>& pid,
-            void (T::*method)(P1, P2, P3),
-            A1 a1, A2 a2, A3 a3)
-{
-  std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk(
-      new std::tr1::function<void(T*)>(
-          std::tr1::bind(method, std::tr1::placeholders::_1, a1, a2, a3)));
-
-  std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-      new std::tr1::function<void(ProcessBase*)>(
-          std::tr1::bind(&internal::vdispatcher<T>,
-                         std::tr1::placeholders::_1,
-                         thunk)));
-
-  std::tr1::function<void(void)> dispatch =
-    std::tr1::bind(internal::dispatch, pid, dispatcher);
-
-  return timers::create(secs, dispatch);
-}
-
 } // namespace process {
 
 #endif // __PROCESS_TIMER_HPP__

Modified: incubator/mesos/trunk/third_party/libprocess/src/process.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/process.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/process.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/process.cpp Mon Apr 30 23:22:45 2012
@@ -46,6 +46,7 @@
 
 #include <process/clock.hpp>
 #include <process/defer.hpp>
+#include <process/delay.hpp>
 #include <process/dispatch.hpp>
 #include <process/executor.hpp>
 #include <process/filter.hpp>

Modified: incubator/mesos/trunk/third_party/libprocess/src/tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/tests.cpp?rev=1332468&r1=1332467&r2=1332468&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/tests.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/tests.cpp Mon Apr 30 23:22:45 2012
@@ -11,6 +11,7 @@
 #include <process/collect.hpp>
 #include <process/clock.hpp>
 #include <process/defer.hpp>
+#include <process/delay.hpp>
 #include <process/dispatch.hpp>
 #include <process/executor.hpp>
 #include <process/filter.hpp>
@@ -18,7 +19,6 @@
 #include <process/gc.hpp>
 #include <process/process.hpp>
 #include <process/run.hpp>
-#include <process/timer.hpp>
 
 #include "encoder.hpp"
 #include "thread.hpp"