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 2014/01/14 21:04:52 UTC

[01/15] git commit: Upgraded Mesos to protobuf 2.5.0.

Updated Branches:
  refs/heads/master 72a1e19aa -> 2dea250c0


Upgraded Mesos to protobuf 2.5.0.

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


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

Branch: refs/heads/master
Commit: 7810f9ed2b68e848f12b2c6d79f2c9312b582b1e
Parents: 2cf8785
Author: Benjamin Hindman <be...@gmail.com>
Authored: Mon Dec 30 11:14:16 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Jan 13 23:38:54 2014 -0800

----------------------------------------------------------------------
 src/Makefile.am                                        | 4 ++--
 src/examples/java/test-exception-framework.in          | 2 +-
 src/examples/java/test-executor.in                     | 2 +-
 src/examples/java/test-framework.in                    | 2 +-
 src/examples/java/test-multiple-executors-framework.in | 2 +-
 src/examples/python/test-executor.in                   | 4 ++--
 src/examples/python/test-framework.in                  | 4 ++--
 src/java/mesos.pom.in                                  | 2 +-
 src/python/setup.py.in                                 | 4 ++--
 9 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 22d23f4..150aafb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -718,8 +718,8 @@ PROTOBUF_EGG = ../$(PROTOBUF)/python/dist/protobuf-$(PROTOBUF_EGG_SUFFIX)
 $(PROTOBUF_EGG):
 	@echo "Building protobuf Python egg ..."
 	cd ../$(PROTOBUF)/python && \
-	   CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
-	   PYTHONPATH=$(DISTRIBUTE_EGG) $(PYTHON) setup.py bdist_egg
+          CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
+	  PYTHONPATH=$(DISTRIBUTE_EGG) $(PYTHON) setup.py build bdist_egg
 
 CLEANFILES += $(PROTOBUF_EGG)
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/examples/java/test-exception-framework.in
----------------------------------------------------------------------
diff --git a/src/examples/java/test-exception-framework.in b/src/examples/java/test-exception-framework.in
index 1d36e06..26617e2 100644
--- a/src/examples/java/test-exception-framework.in
+++ b/src/examples/java/test-exception-framework.in
@@ -12,7 +12,7 @@ JAVA=${JAVA-${JAVA_HOME}/bin/java}
 # Use colors for errors.
 . ${MESOS_SOURCE_DIR}/support/colors.sh
 
-PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.4.1.jar
+PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.5.0.jar
 
 test ! -e ${PROTOBUF_JAR} && \
   echo "${RED}Failed to find ${PROTOBUF_JAR}${NORMAL}" && \

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/examples/java/test-executor.in
----------------------------------------------------------------------
diff --git a/src/examples/java/test-executor.in b/src/examples/java/test-executor.in
index 896ff1d..8b27a37 100644
--- a/src/examples/java/test-executor.in
+++ b/src/examples/java/test-executor.in
@@ -12,7 +12,7 @@ JAVA=${JAVA-${JAVA_HOME}/bin/java}
 # Use colors for errors.
 . ${MESOS_SOURCE_DIR}/support/colors.sh
 
-PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.4.1.jar
+PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.5.0.jar
 
 test ! -e ${PROTOBUF_JAR} && \
   echo "${RED}Failed to find ${PROTOBUF_JAR}${NORMAL}" && \

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/examples/java/test-framework.in
----------------------------------------------------------------------
diff --git a/src/examples/java/test-framework.in b/src/examples/java/test-framework.in
index b095f61..bbdc1ed 100644
--- a/src/examples/java/test-framework.in
+++ b/src/examples/java/test-framework.in
@@ -12,7 +12,7 @@ JAVA=${JAVA-${JAVA_HOME}/bin/java}
 # Use colors for errors.
 . ${MESOS_SOURCE_DIR}/support/colors.sh
 
-PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.4.1.jar
+PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.5.0.jar
 
 test ! -e ${PROTOBUF_JAR} && \
   echo "${RED}Failed to find ${PROTOBUF_JAR}${NORMAL}" && \

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/examples/java/test-multiple-executors-framework.in
----------------------------------------------------------------------
diff --git a/src/examples/java/test-multiple-executors-framework.in b/src/examples/java/test-multiple-executors-framework.in
index c4915fc..eb8edf6 100644
--- a/src/examples/java/test-multiple-executors-framework.in
+++ b/src/examples/java/test-multiple-executors-framework.in
@@ -12,7 +12,7 @@ JAVA=${JAVA-${JAVA_HOME}/bin/java}
 # Use colors for errors.
 . ${MESOS_SOURCE_DIR}/support/colors.sh
 
-PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.4.1.jar
+PROTOBUF_JAR=${MESOS_BUILD_DIR}/protobuf-2.5.0.jar
 
 test ! -e ${PROTOBUF_JAR} && \
   echo "${RED}Failed to find ${PROTOBUF_JAR}${NORMAL}" && \

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/examples/python/test-executor.in
----------------------------------------------------------------------
diff --git a/src/examples/python/test-executor.in b/src/examples/python/test-executor.in
index 773349b..7e8875f 100644
--- a/src/examples/python/test-executor.in
+++ b/src/examples/python/test-executor.in
@@ -21,10 +21,10 @@ test ! -e ${DISTRIBUTE_EGG} && \
   echo "${RED}Failed to find ${DISTRIBUTE_EGG}${NORMAL}" && \
   exit 1
 
-PROTOBUF=${MESOS_BUILD_DIR}/3rdparty/libprocess/3rdparty/protobuf-2.4.1
+PROTOBUF=${MESOS_BUILD_DIR}/3rdparty/libprocess/3rdparty/protobuf-2.5.0
 
 PROTOBUF_EGG=${PROTOBUF}/python/dist/
-PROTOBUF_EGG+=protobuf-2.4.1@PYTHON_EGG_PUREPY_POSTFIX@.egg
+PROTOBUF_EGG+=protobuf-2.5.0@PYTHON_EGG_PUREPY_POSTFIX@.egg
 
 test ! -e ${PROTOBUF_EGG} && \
   echo "${RED}Failed to find ${PROTOBUF_EGG}${NORMAL}" && \

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/examples/python/test-framework.in
----------------------------------------------------------------------
diff --git a/src/examples/python/test-framework.in b/src/examples/python/test-framework.in
index 68b1387..c4683b9 100644
--- a/src/examples/python/test-framework.in
+++ b/src/examples/python/test-framework.in
@@ -21,10 +21,10 @@ test ! -e ${DISTRIBUTE_EGG} && \
   echo "${RED}Failed to find ${DISTRIBUTE_EGG}${NORMAL}" && \
   exit 1
 
-PROTOBUF=${MESOS_BUILD_DIR}/3rdparty/libprocess/3rdparty/protobuf-2.4.1
+PROTOBUF=${MESOS_BUILD_DIR}/3rdparty/libprocess/3rdparty/protobuf-2.5.0
 
 PROTOBUF_EGG=${PROTOBUF}/python/dist/
-PROTOBUF_EGG+=protobuf-2.4.1@PYTHON_EGG_PUREPY_POSTFIX@.egg
+PROTOBUF_EGG+=protobuf-2.5.0@PYTHON_EGG_PUREPY_POSTFIX@.egg
 
 test ! -e ${PROTOBUF_EGG} && \
   echo "${RED}Failed to find ${PROTOBUF_EGG}${NORMAL}" && \

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/java/mesos.pom.in
----------------------------------------------------------------------
diff --git a/src/java/mesos.pom.in b/src/java/mesos.pom.in
index f817c94..581c563 100644
--- a/src/java/mesos.pom.in
+++ b/src/java/mesos.pom.in
@@ -83,7 +83,7 @@
     <dependency>
       <artifactId>protobuf-java</artifactId>
       <groupId>com.google.protobuf</groupId>
-      <version>2.4.1</version>
+      <version>2.5.0</version>
     </dependency>
   </dependencies>
   <build>

http://git-wip-us.apache.org/repos/asf/mesos/blob/7810f9ed/src/python/setup.py.in
----------------------------------------------------------------------
diff --git a/src/python/setup.py.in b/src/python/setup.py.in
index 77fa880..47cea7c 100644
--- a/src/python/setup.py.in
+++ b/src/python/setup.py.in
@@ -32,7 +32,7 @@ libprocess = os.path.join('3rdparty', 'libprocess')
 glog = os.path.join(libprocess, '3rdparty', 'glog-0.3.3')
 libev = os.path.join(libprocess, '3rdparty', 'libev-4.15')
 gperftools = os.path.join(libprocess, '3rdparty', 'gperftools-2.0')
-protobuf = os.path.join(libprocess, '3rdparty', 'protobuf-2.4.1')
+protobuf = os.path.join(libprocess, '3rdparty', 'protobuf-2.5.0')
 
 # We need to execute from the same directory as this script.
 os.chdir(os.path.abspath(os.path.dirname(__file__)))
@@ -118,5 +118,5 @@ setup(name = 'mesos',
       description = 'Mesos',
       package_dir = { '': 'src' },
       packages = ['.'],
-      install_requires = ['protobuf>=2.4.1'],
+      install_requires = ['protobuf>=2.5.0'],
       ext_modules = [mesos_module])


[15/15] git commit: Refactorings necessary to get Mesos to compile with clang.

Posted by be...@apache.org.
Refactorings necessary to get Mesos to compile with clang.

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


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

Branch: refs/heads/master
Commit: a2792e628be1eac1e834f31e049a0b5d90964e52
Parents: 02bd848
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:57:47 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:01:11 2014 -0800

----------------------------------------------------------------------
 include/mesos/executor.hpp          |  2 ++
 include/mesos/scheduler.hpp         |  2 ++
 src/files/files.cpp                 |  1 +
 src/master/allocator.hpp            |  3 +++
 src/master/contender.cpp            |  5 ++++-
 src/master/http.cpp                 |  8 ++++----
 src/master/master.cpp               |  2 +-
 src/master/master.hpp               |  7 +++++--
 src/master/registrar.cpp            |  5 +++--
 src/slave/http.cpp                  |  4 ++--
 src/slave/isolator.hpp              |  5 ++++-
 src/slave/slave.cpp                 |  5 ++---
 src/slave/slave.hpp                 | 29 ++++++++++++++++++++++-------
 src/slave/status_update_manager.cpp |  4 +++-
 src/state/state.hpp                 |  1 +
 15 files changed, 59 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/include/mesos/executor.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/executor.hpp b/include/mesos/executor.hpp
index 9b25834..7bc8eca 100644
--- a/include/mesos/executor.hpp
+++ b/include/mesos/executor.hpp
@@ -19,6 +19,8 @@
 #ifndef __MESOS_EXECUTOR_HPP__
 #define __MESOS_EXECUTOR_HPP__
 
+#include <pthread.h>
+
 #include <string>
 
 #include <mesos/mesos.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/include/mesos/scheduler.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/scheduler.hpp b/include/mesos/scheduler.hpp
index 161cc65..8063997 100644
--- a/include/mesos/scheduler.hpp
+++ b/include/mesos/scheduler.hpp
@@ -19,6 +19,8 @@
 #ifndef __MESOS_SCHEDULER_HPP__
 #define __MESOS_SCHEDULER_HPP__
 
+#include <pthread.h>
+
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index 45ef95c..3dacc66 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -9,6 +9,7 @@
 
 #include <boost/shared_array.hpp>
 
+#include <process/deferred.hpp> // TODO(benh): This is required by Clang.
 #include <process/dispatch.hpp>
 #include <process/future.hpp>
 #include <process/http.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/master/allocator.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator.hpp b/src/master/allocator.hpp
index 85ed214..2e6a910 100644
--- a/src/master/allocator.hpp
+++ b/src/master/allocator.hpp
@@ -57,6 +57,9 @@ public:
 
   virtual ~AllocatorProcess() {}
 
+  // Explicitely use 'initialize' since we're overloading below.
+  using process::ProcessBase::initialize;
+
   virtual void initialize(
       const Flags& flags,
       const process::PID<Master>& master,

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/master/contender.cpp
----------------------------------------------------------------------
diff --git a/src/master/contender.cpp b/src/master/contender.cpp
index 84b0552..72a7796 100644
--- a/src/master/contender.cpp
+++ b/src/master/contender.cpp
@@ -49,7 +49,10 @@ class ZooKeeperMasterContenderProcess
 public:
   ZooKeeperMasterContenderProcess(const zookeeper::URL& url);
   ZooKeeperMasterContenderProcess(Owned<zookeeper::Group> group);
-  ~ZooKeeperMasterContenderProcess();
+  virtual ~ZooKeeperMasterContenderProcess();
+
+  // Explicitely use 'initialize' since we're overloading below.
+  using process::ProcessBase::initialize;
 
   void initialize(const PID<Master>& master);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 5eee60f..231041d 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -199,8 +199,8 @@ JSON::Object model(const Framework& framework)
   // Model all of the completed tasks of a framework.
   {
     JSON::Array array;
-    foreach (const Task& task, framework.completedTasks) {
-      array.values.push_back(model(task));
+    foreach (const memory::shared_ptr<Task>& task, framework.completedTasks) {
+      array.values.push_back(model(*task));
     }
 
     object.values["completed_tasks"] = array;
@@ -551,8 +551,8 @@ Future<Response> Master::Http::tasks(const Request& request)
       CHECK_NOTNULL(task);
       tasks.push_back(task);
     }
-    foreach (const Task& task, framework->completedTasks) {
-      tasks.push_back(&task);
+    foreach (const memory::shared_ptr<Task>& task, framework->completedTasks) {
+      tasks.push_back(task.get());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index fa1277a..008033e 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -671,7 +671,7 @@ void Master::fileAttached(const Future<Nothing>& result, const string& path)
     LOG(INFO) << "Successfully attached file '" << path << "'";
   } else {
     LOG(ERROR) << "Failed to attach file '" << path << "': "
-               << result.isFailed() ? result.failure() : "discarded";
+               << (result.isFailed() ? result.failure() : "discarded");
   }
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 10feb93..6e89149 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -565,7 +565,7 @@ struct Framework
       << "Unknown task " << task->task_id()
       << " of framework " << task->framework_id();
 
-    completedTasks.push_back(*task);
+    completedTasks.push_back(memory::shared_ptr<Task>(new Task(*task)));
     tasks.erase(task->task_id());
     resources -= task->resources();
   }
@@ -633,7 +633,10 @@ struct Framework
 
   hashmap<TaskID, Task*> tasks;
 
-  boost::circular_buffer<Task> completedTasks;
+  // NOTE: We use a shared pointer for Task because clang doesn't like
+  // Boost's implementation of circular_buffer with Task (Boost
+  // attempts to do some memset's which are unsafe).
+  boost::circular_buffer<memory::shared_ptr<Task> > completedTasks;
 
   hashset<Offer*> offers; // Active offers for framework.
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/master/registrar.cpp
----------------------------------------------------------------------
diff --git a/src/master/registrar.cpp b/src/master/registrar.cpp
index 61fdea3..915885a 100644
--- a/src/master/registrar.cpp
+++ b/src/master/registrar.cpp
@@ -208,8 +208,9 @@ void RegistrarProcess::_recover(
   CHECK(!recovery.isPending());
 
   if (recovery.isFailed() || recovery.isDiscarded()) {
-    LOG(WARNING) << "Failed to recover registrar: " << recovery.isFailed()
-      ? recovery.failure() : "future discarded";
+    LOG(WARNING)
+      << "Failed to recover registrar: "
+      << (recovery.isFailed() ? recovery.failure() : "future discarded");
     recover(); // Retry! TODO(benh): Don't retry forever?
   } else {
     LOG(INFO) << "Successfully recovered registrar";

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 1358810..4876364 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -218,8 +218,8 @@ JSON::Object model(const Executor& executor)
   object.values["queued_tasks"] = queued;
 
   JSON::Array completed;
-  foreach (const Task& task, executor.completedTasks) {
-    completed.values.push_back(model(task));
+  foreach (const memory::shared_ptr<Task>& task, executor.completedTasks) {
+    completed.values.push_back(model(*task));
   }
 
   // NOTE: We add 'terminatedTasks' to 'completed_tasks' for

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/slave/isolator.hpp
----------------------------------------------------------------------
diff --git a/src/slave/isolator.hpp b/src/slave/isolator.hpp
index fc13089..9634535 100644
--- a/src/slave/isolator.hpp
+++ b/src/slave/isolator.hpp
@@ -41,7 +41,7 @@ namespace internal {
 namespace slave {
 namespace state {
 
-class SlaveState; // Forward declaration.
+struct SlaveState; // Forward declaration.
 
 } // namespace state {
 
@@ -57,6 +57,9 @@ public:
 
   virtual ~Isolator() {}
 
+  // Explicitely use 'initialize' since we're overloading below.
+  using process::ProcessBase::initialize;
+
   // Called during slave initialization.
   virtual void initialize(
       const Flags& flags,

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 57d58b3..8b83dac 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -465,7 +465,7 @@ void Slave::fileAttached(const Future<Nothing>& result, const string& path)
     VLOG(1) << "Successfully attached file '" << path << "'";
   } else {
     LOG(ERROR) << "Failed to attach file '" << path << "': "
-               << result.isFailed() ? result.failure() : "discarded";
+               << (result.isFailed() ? result.failure() : "discarded");
   }
 }
 
@@ -3229,9 +3229,8 @@ void Executor::completeTask(const TaskID& taskId)
     << "Failed to find terminated task " << taskId;
 
   Task* task = terminatedTasks[taskId];
-  completedTasks.push_back(*task);
+  completedTasks.push_back(memory::shared_ptr<Task>(task));
   terminatedTasks.erase(taskId);
-  delete task;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 34edef2..38ba7b6 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -211,7 +211,10 @@ public:
     TERMINATING,  // Slave is shutting down.
   } state;
 
-protected:
+  // TODO(benh): Clang requires members to be public in order to take
+  // their address which we do in tests (for things like
+  // FUTURE_DISPATCH).
+// protected:
   virtual void initialize();
   virtual void finalize();
   virtual void exited(const UPID& pid);
@@ -304,8 +307,8 @@ private:
     const Slave& slave;
   } http;
 
-  friend class Framework;
-  friend class Executor;
+  friend struct Framework;
+  friend struct Executor;
 
   Slave(const Slave&);              // No copying.
   Slave& operator = (const Slave&); // No assigning.
@@ -410,10 +413,22 @@ struct Executor
 
   Resources resources; // Currently consumed resources.
 
-  LinkedHashMap<TaskID, TaskInfo> queuedTasks; // Not yet launched.
-  LinkedHashMap<TaskID, Task*> launchedTasks;  // Running.
-  LinkedHashMap<TaskID, Task*> terminatedTasks; // Terminated but pending updates.
-  boost::circular_buffer<Task> completedTasks; // Terminated and updates acked.
+  // Tasks can be found in one of the following four data structures:
+
+  // Not yet launched.
+  LinkedHashMap<TaskID, TaskInfo> queuedTasks;
+
+  // Running.
+  LinkedHashMap<TaskID, Task*> launchedTasks;
+
+  // Terminated but pending updates.
+  LinkedHashMap<TaskID, Task*> terminatedTasks;
+
+  // Terminated and updates acked.
+  // NOTE: We use a shared pointer for Task because clang doesn't like
+  // Boost's implementation of circular_buffer with Task (Boost
+  // attempts to do some memset's which are unsafe).
+  boost::circular_buffer<memory::shared_ptr<Task> > completedTasks;
 
 private:
   Executor(const Executor&);              // No copying.

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/slave/status_update_manager.cpp
----------------------------------------------------------------------
diff --git a/src/slave/status_update_manager.cpp b/src/slave/status_update_manager.cpp
index f7a0c40..03f5eaf 100644
--- a/src/slave/status_update_manager.cpp
+++ b/src/slave/status_update_manager.cpp
@@ -59,8 +59,10 @@ public:
   StatusUpdateManagerProcess() {}
   virtual ~StatusUpdateManagerProcess();
 
-  // StatusUpdateManager implementation.
+  // Explicitely use 'initialize' since we're overloading below.
+  using process::ProcessBase::initialize;
 
+  // StatusUpdateManager implementation.
   void initialize(
       const Flags& flags,
       const PID<Slave>& slave);

http://git-wip-us.apache.org/repos/asf/mesos/blob/a2792e62/src/state/state.hpp
----------------------------------------------------------------------
diff --git a/src/state/state.hpp b/src/state/state.hpp
index 02620b3..133752d 100644
--- a/src/state/state.hpp
+++ b/src/state/state.hpp
@@ -22,6 +22,7 @@
 #include <string>
 #include <vector>
 
+#include <process/deferred.hpp> // TODO(benh): This is required by Clang.
 #include <process/future.hpp>
 
 #include <stout/lambda.hpp>


[11/15] git commit: Upgraded to ZooKeeper 3.4.5.

Posted by be...@apache.org.
Upgraded to ZooKeeper 3.4.5.

In order to build Mesos with clang we need to upgrade
ZooKeeper. Unfortunately, Mesos leveraged some internal APIs of
ZooKeeper that changed so this commit required some refactorings.

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


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

Branch: refs/heads/master
Commit: 9bfbc2c3197e29e50ff8c36544fb6a8d9eafdca9
Parents: 70aeb47
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:42:19 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:00:40 2014 -0800

----------------------------------------------------------------------
 3rdparty/versions.am                |   2 +-
 3rdparty/zookeeper-3.3.4.tar.gz     | Bin 13543276 -> 0 bytes
 3rdparty/zookeeper-3.4.5.tar.gz     | Bin 0 -> 16402010 bytes
 src/Makefile.am                     |   1 +
 src/jvm/jvm.cpp                     | 106 +++++++++++++++++++++++++++-
 src/jvm/jvm.hpp                     |  82 ++++++++++++++++++++--
 src/jvm/org/apache/log4j.cpp        |   5 +-
 src/jvm/org/apache/log4j.hpp        |   5 +-
 src/jvm/org/apache/zookeeper.cpp    |  15 ++++
 src/jvm/org/apache/zookeeper.hpp    | 115 +++++++++++++++++--------------
 src/python/setup.py.in              |   2 +-
 src/tests/zookeeper.cpp             |  38 +++++++---
 src/tests/zookeeper_test_server.cpp |  53 +++++++++-----
 src/tests/zookeeper_test_server.hpp |   2 +-
 14 files changed, 328 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/3rdparty/versions.am
----------------------------------------------------------------------
diff --git a/3rdparty/versions.am b/3rdparty/versions.am
index 5932e1f..102d6f4 100644
--- a/3rdparty/versions.am
+++ b/3rdparty/versions.am
@@ -21,4 +21,4 @@
 
 BOTO_VERSION = 2.0b2
 DISTRIBUTE_VERSION = 0.6.26
-ZOOKEEPER_VERSION = 3.3.4
+ZOOKEEPER_VERSION = 3.4.5

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/3rdparty/zookeeper-3.3.4.tar.gz
----------------------------------------------------------------------
diff --git a/3rdparty/zookeeper-3.3.4.tar.gz b/3rdparty/zookeeper-3.3.4.tar.gz
deleted file mode 100644
index 09d4924..0000000
Binary files a/3rdparty/zookeeper-3.3.4.tar.gz and /dev/null differ

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/3rdparty/zookeeper-3.4.5.tar.gz
----------------------------------------------------------------------
diff --git a/3rdparty/zookeeper-3.4.5.tar.gz b/3rdparty/zookeeper-3.4.5.tar.gz
new file mode 100644
index 0000000..1a547fe
Binary files /dev/null and b/3rdparty/zookeeper-3.4.5.tar.gz differ

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 4f04dc6..288a5cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -598,6 +598,7 @@ libjava_la_SOURCES =							\
 	jvm/java/net.hpp						\
 	jvm/org/apache/log4j.cpp					\
 	jvm/org/apache/log4j.hpp					\
+	jvm/org/apache/zookeeper.cpp					\
 	jvm/org/apache/zookeeper.hpp
 
 libjava_la_CPPFLAGS = $(MESOS_CPPFLAGS)

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/jvm/jvm.cpp
----------------------------------------------------------------------
diff --git a/src/jvm/jvm.cpp b/src/jvm/jvm.cpp
index 17ab12e..6eb3a34 100644
--- a/src/jvm/jvm.cpp
+++ b/src/jvm/jvm.cpp
@@ -272,14 +272,35 @@ Jvm::Method Jvm::findStaticMethod(const MethodSignature& signature)
 }
 
 
-Jvm::Field Jvm::findStaticField(const Class& clazz, const std::string& name)
+Jvm::Field Jvm::findField(
+    const Class& clazz,
+    const std::string& name,
+    const std::string& signature)
+{
+  Env env;
+
+  jfieldID id = env->GetFieldID(
+      findClass(clazz),
+      name.c_str(),
+      signature.c_str());
+
+  check(env);
+
+  return Jvm::Field(clazz, id);
+}
+
+
+Jvm::Field Jvm::findStaticField(
+    const Class& clazz,
+    const std::string& name,
+    const std::string& signature)
 {
   Env env;
 
   jfieldID id = env->GetStaticFieldID(
       findClass(clazz),
       name.c_str(),
-      clazz.signature().c_str());
+      signature.c_str());
 
   check(env);
 
@@ -300,6 +321,78 @@ jobject Jvm::invoke(const Constructor& ctor, ...)
 
 
 template <>
+void Jvm::setField<jobject>(jobject receiver, const Field& field, jobject o)
+{
+  Env env;
+  env->SetObjectField(receiver, field.id, o);
+  check(env);
+}
+
+
+template <>
+void Jvm::setField<bool>(jobject receiver, const Field& field, bool b)
+{
+  Env env;
+  env->SetBooleanField(receiver, field.id, b);
+  check(env);
+}
+
+
+template <>
+void Jvm::setField<char>(jobject receiver, const Field& field, char c)
+{
+  Env env;
+  env->SetCharField(receiver, field.id, c);
+  check(env);
+}
+
+
+template <>
+void Jvm::setField<short>(jobject receiver, const Field& field, short s)
+{
+  Env env;
+  env->SetShortField(receiver, field.id, s);
+  check(env);
+}
+
+
+template <>
+void Jvm::setField<int>(jobject receiver, const Field& field, int i)
+{
+  Env env;
+  env->SetIntField(receiver, field.id, i);
+  check(env);
+}
+
+
+template <>
+void Jvm::setField<long>(jobject receiver, const Field& field, long l)
+{
+  Env env;
+  env->SetLongField(receiver, field.id, l);
+  check(env);
+}
+
+
+template <>
+void Jvm::setField<float>(jobject receiver, const Field& field, float f)
+{
+  Env env;
+  env->SetFloatField(receiver, field.id, f);
+  check(env);
+}
+
+
+template <>
+void Jvm::setField<double>(jobject receiver, const Field& field, double d)
+{
+  Env env;
+  env->SetDoubleField(receiver, field.id, d);
+  check(env);
+}
+
+
+template <>
 jobject Jvm::getStaticField<jobject>(const Field& field)
 {
   Env env;
@@ -421,9 +514,16 @@ jclass Jvm::findClass(const Class& clazz)
 {
   Env env;
 
+  jclass jclazz = env->FindClass(clazz.name.c_str());
+
+  if (env->ExceptionCheck()) {
+    env->ExceptionDescribe();
+    LOG(FATAL) << "Failed to find class " << clazz.name;
+  }
+
   // TODO(John Sirois): Consider CHECK_NOTNULL -> return Option if
   // re-purposing this code outside of tests.
-  return CHECK_NOTNULL(env->FindClass(clazz.name.c_str()));
+  return CHECK_NOTNULL(jclazz);
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/jvm/jvm.hpp
----------------------------------------------------------------------
diff --git a/src/jvm/jvm.hpp b/src/jvm/jvm.hpp
index a3ea86a..b4dff78 100644
--- a/src/jvm/jvm.hpp
+++ b/src/jvm/jvm.hpp
@@ -234,8 +234,11 @@ public:
       : object(Jvm::get()->newGlobalRef(_object)) {}
 
     Object(const Object& that)
+      : object(NULL)
     {
-      object = Jvm::get()->newGlobalRef(that.object);
+      if (that.object != NULL) {
+        object = Jvm::get()->newGlobalRef(that.object);
+      }
     }
 
     ~Object()
@@ -249,8 +252,11 @@ public:
     {
       if (object != NULL) {
         Jvm::get()->deleteGlobalRef(object);
+        object = NULL;
+      }
+      if (that.object != NULL) {
+        object = Jvm::get()->newGlobalRef(that.object);
       }
-      object = Jvm::get()->newGlobalRef(that.object);
       return *this;
     }
 
@@ -265,16 +271,63 @@ public:
     jobject object;
   };
 
+
+  class Null : public Object {};
+
+
+  template <typename T, const char* name, const char* signature>
+  class Variable
+  {
+  public:
+    Variable(const Class& _clazz)
+      : clazz(_clazz)
+    {
+      // Check that T extends Object.
+      { T* t = NULL; Object* o = t; (void) o; }
+    }
+
+    Variable(const Class& _clazz, const Object& _object)
+      : clazz(_clazz), object(_object)
+    {
+      // Check that T extends Object.
+      { T* t = NULL; Object* o = t; (void) o; }
+    }
+
+    // TODO(benh): Implement cast operator (like in StaticVariable).
+    // This requires implementing Jvm::getField too.
+
+    template <typename U>
+    Variable& operator = (const U& u)
+    {
+      // Check that U extends Object (but not necessarily T since U
+      // might be 'Null').
+      { U* u = NULL; Object* o = u; (void) o; }
+
+      // Note that we actually look up the field lazily (upon first
+      // assignment operator) so that we don't possibly create the JVM
+      // too early.
+      static Field field = Jvm::get()->findField(clazz, name, signature);
+
+      Jvm::get()->setField<jobject>(object, field, u);
+
+      return *this;
+    }
+
+    void bind(const Object& _object) { object = _object; }
+
+  private:
+    const Class clazz;
+    Object object; // Not const so we can do late binding.
+  };
+
   // Helper for providing access to static variables in a class. You
   // can use this to delay the variable lookup until it's actually
   // accessed in order to keep the JVM from getting constructed too
   // early. See Level in jvm/org/apache/log4j.hpp for an example.
-  // TODO(benh): Make this work for instance variables too (i.e.,
-  // StaticVariable -> Variable).
   // TODO(benh): Provide template specialization for primitive
   // types (e.g., StaticVariable<int>, StaticVariable<short>,
   // StaticVariable<std::string>).
-  template <typename T, const char* name>
+  template <typename T, const char* name, const char* signature>
   class StaticVariable
   {
   public:
@@ -290,7 +343,8 @@ public:
       // Note that we actually look up the field lazily (upon first
       // invocation operator) so that we don't possibly create the JVM
       // too early.
-      static Field field = Jvm::get()->findStaticField(clazz, name);
+      static Field field =
+        Jvm::get()->findStaticField(clazz, name, signature);
       T t;
       t.object = Jvm::get()->getStaticField<jobject>(field);
       return t;
@@ -339,9 +393,20 @@ public:
   jstring string(const std::string& s);
 
   Constructor findConstructor(const ConstructorFinder& finder);
+
   Method findMethod(const MethodSignature& signature);
+
   Method findStaticMethod(const MethodSignature& signature);
-  Field findStaticField(const Class& clazz, const std::string& name);
+
+  Field findField(
+      const Class& clazz,
+      const std::string& name,
+      const std::string& signature);
+
+  Field findStaticField(
+      const Class& clazz,
+      const std::string& name,
+      const std::string& signature);
 
   // TODO(John Sirois): Add "type checking" to variadic method
   // calls. Possibly a way to do this with typelists, type
@@ -356,6 +421,9 @@ public:
   T invokeStatic(const Method& method, ...);
 
   template <typename T>
+  void setField(jobject receiver, const Field& field, T t);
+
+  template <typename T>
   T getStaticField(const Field& field);
 
   // Checks the exception state of an environment.

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/jvm/org/apache/log4j.cpp
----------------------------------------------------------------------
diff --git a/src/jvm/org/apache/log4j.cpp b/src/jvm/org/apache/log4j.cpp
index b73df8c..105629c 100644
--- a/src/jvm/org/apache/log4j.cpp
+++ b/src/jvm/org/apache/log4j.cpp
@@ -5,10 +5,11 @@ namespace apache {
 namespace log4j {
 
 // Static storage and initialization.
+const char LEVEL_OFF_SIGNATURE[] = "Lorg/apache/log4j/Level;";
 const char LEVEL_OFF[] = "OFF";
 
-Jvm::StaticVariable<Level, LEVEL_OFF> Level::OFF =
-  Jvm::StaticVariable<Level, LEVEL_OFF>(
+Jvm::StaticVariable<Level, LEVEL_OFF, LEVEL_OFF_SIGNATURE> Level::OFF =
+  Jvm::StaticVariable<Level, LEVEL_OFF, LEVEL_OFF_SIGNATURE>(
       Jvm::Class::named("org/apache/log4j/Level"));
 
 } // namespace log4j {

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/jvm/org/apache/log4j.hpp
----------------------------------------------------------------------
diff --git a/src/jvm/org/apache/log4j.hpp b/src/jvm/org/apache/log4j.hpp
index 6b5ba4b..0913a6b 100644
--- a/src/jvm/org/apache/log4j.hpp
+++ b/src/jvm/org/apache/log4j.hpp
@@ -8,15 +8,16 @@ namespace apache {
 namespace log4j {
 
 // Forward declaration.
+extern const char LEVEL_OFF_SIGNATURE[];
 extern const char LEVEL_OFF[];
 
 
 class Level : public Jvm::Object // TODO(benh): Extends Priority.
 {
 public:
-  friend class Jvm::StaticVariable<Level, LEVEL_OFF>;
+  friend class Jvm::StaticVariable<Level, LEVEL_OFF, LEVEL_OFF_SIGNATURE>;
 
-  static Jvm::StaticVariable<Level, LEVEL_OFF> OFF;
+  static Jvm::StaticVariable<Level, LEVEL_OFF, LEVEL_OFF_SIGNATURE> OFF;
 
   Level() {} // No default constuctors.
 };

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/jvm/org/apache/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/jvm/org/apache/zookeeper.cpp b/src/jvm/org/apache/zookeeper.cpp
new file mode 100644
index 0000000..192b647
--- /dev/null
+++ b/src/jvm/org/apache/zookeeper.cpp
@@ -0,0 +1,15 @@
+#include <jvm/org/apache/zookeeper.hpp>
+
+namespace org {
+namespace apache {
+namespace zookeeper {
+namespace server {
+
+const char ZOOKEEPERSERVER_SESSIONTRACKER_SIGNATURE[] =
+  "Lorg/apache/zookeeper/server/SessionTracker;";
+const char ZOOKEEPERSERVER_SESSIONTRACKER[] = "sessionTracker";
+
+} // namespace server {
+} // namespace zookeeper {
+} // namespace apache {
+} // namespace org {

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/jvm/org/apache/zookeeper.hpp
----------------------------------------------------------------------
diff --git a/src/jvm/org/apache/zookeeper.hpp b/src/jvm/org/apache/zookeeper.hpp
index 2b78a25..392e749 100644
--- a/src/jvm/org/apache/zookeeper.hpp
+++ b/src/jvm/org/apache/zookeeper.hpp
@@ -6,11 +6,16 @@
 #include <jvm/java/io.hpp>
 #include <jvm/java/net.hpp>
 
-// Package 'org.apache.zookeeper.persistence'.
+
+// Package 'org.apache.zookeeper.server'.
 
 namespace org {
 namespace apache {
 namespace zookeeper {
+namespace server {
+
+// Package 'org.apache.zookeeper.server.persistence'.
+
 namespace persistence {
 
 class FileTxnSnapLog : public Jvm::Object
@@ -32,17 +37,14 @@ public:
 };
 
 } // namespace persistence {
-} // namespace zookeeper {
-} // namespace apache {
-} // namespace org {
 
 
-// Package 'org.apache.zookeeper.server'.
+class SessionTracker : public Jvm::Object {};
+
+
+extern const char ZOOKEEPERSERVER_SESSIONTRACKER_SIGNATURE[];
+extern const char ZOOKEEPERSERVER_SESSIONTRACKER[];
 
-namespace org {
-namespace apache {
-namespace zookeeper {
-namespace server {
 
 class ZooKeeperServer : public Jvm::Object
 {
@@ -65,6 +67,8 @@ public:
 
   ZooKeeperServer(const persistence::FileTxnSnapLog& txnLogFactory,
                   const DataTreeBuilder& treeBuilder)
+    : sessionTracker(
+        Jvm::Class::named("org/apache/zookeeper/server/ZooKeeperServer"))
   {
     static Jvm::Constructor constructor = Jvm::get()->findConstructor(
         Jvm::Class::named("org/apache/zookeeper/server/ZooKeeperServer")
@@ -78,6 +82,11 @@ public:
 
     object = Jvm::get()->invoke(
         constructor, (jobject) txnLogFactory, (jobject) treeBuilder);
+
+    // We need to "bind" the 'sessionTracker' Variable after we assign
+    // 'object' above so that '*this' is a Jvm::Object instance that
+    // doesn't point to a NULL jobject.
+    sessionTracker.bind(*this);
   }
 
   void setMaxSessionTimeout(int max)
@@ -142,64 +151,64 @@ public:
 
     Jvm::get()->invoke<void>(object, method, sessionId);
   }
+
+  Jvm::Variable<SessionTracker,
+                ZOOKEEPERSERVER_SESSIONTRACKER,
+                ZOOKEEPERSERVER_SESSIONTRACKER_SIGNATURE> sessionTracker;
 };
 
 
-class NIOServerCnxn : public Jvm::Object
+// TODO(benh): Extends ServerCnxnFactory implements Runnable.
+class NIOServerCnxnFactory : public Jvm::Object
 {
 public:
-  class Factory : public Jvm::Object // TODO(benh): Extends Thread.
+  NIOServerCnxnFactory()
   {
-  public:
-    Factory(const java::net::InetSocketAddress& addr)
-    {
-      static Jvm::Constructor constructor = Jvm::get()->findConstructor(
-          Jvm::Class::named(
-              "org/apache/zookeeper/server/NIOServerCnxn$Factory")
-          .constructor()
-          .parameter(Jvm::Class::named("java/net/InetSocketAddress")));
+    static Jvm::Constructor constructor = Jvm::get()->findConstructor(
+        Jvm::Class::named(
+            "org/apache/zookeeper/server/NIOServerCnxnFactory")
+        .constructor());
 
-      object = Jvm::get()->invoke(constructor, (jobject) addr);
-    }
+    object = Jvm::get()->invoke(constructor);
+  }
 
-    void startup(const ZooKeeperServer& zks)
-    {
-      static Jvm::Method method = Jvm::get()->findMethod(
-          Jvm::Class::named(
-              "org/apache/zookeeper/server/NIOServerCnxn$Factory")
-          .method("startup")
-          .parameter(Jvm::Class::named(
-                         "org/apache/zookeeper/server/ZooKeeperServer"))
-          .returns(Jvm::get()->voidClass));
+  void configure(const java::net::InetSocketAddress& addr, int maxcc)
+  {
+    static Jvm::Method method = Jvm::get()->findMethod(
+        Jvm::Class::named(
+            "org/apache/zookeeper/server/NIOServerCnxnFactory")
+        .method("configure")
+        .parameter(Jvm::Class::named("java/net/InetSocketAddress"))
+        .parameter(Jvm::get()->intClass)
+        .returns(Jvm::get()->voidClass));
 
-      Jvm::get()->invoke<void>(object, method, (jobject) zks);
-    }
 
-    bool isAlive()
-    {
-      static Jvm::Method method = Jvm::get()->findMethod(
-          Jvm::Class::named(
-              "org/apache/zookeeper/server/NIOServerCnxn$Factory")
-          .method("isAlive")
-          .returns(Jvm::get()->booleanClass));
+    Jvm::get()->invoke<void>(object, method, (jobject) addr, maxcc);
+  }
 
-      return Jvm::get()->invoke<bool>(object, method);
-    }
+  void startup(const ZooKeeperServer& zks)
+  {
+    static Jvm::Method method = Jvm::get()->findMethod(
+        Jvm::Class::named(
+            "org/apache/zookeeper/server/NIOServerCnxnFactory")
+        .method("startup")
+        .parameter(Jvm::Class::named(
+                       "org/apache/zookeeper/server/ZooKeeperServer"))
+        .returns(Jvm::get()->voidClass));
 
-    void shutdown()
-    {
-      static Jvm::Method method = Jvm::get()->findMethod(
-          Jvm::Class::named(
-              "org/apache/zookeeper/server/NIOServerCnxn$Factory")
-          .method("shutdown")
-          .returns(Jvm::get()->voidClass));
+    Jvm::get()->invoke<void>(object, method, (jobject) zks);
+  }
 
-      Jvm::get()->invoke<void>(object, method);
-    }
-  };
+  void shutdown()
+  {
+    static Jvm::Method method = Jvm::get()->findMethod(
+        Jvm::Class::named(
+            "org/apache/zookeeper/server/NIOServerCnxnFactory")
+        .method("shutdown")
+        .returns(Jvm::get()->voidClass));
 
-private:
-  NIOServerCnxn() {} // No default constructors.
+    Jvm::get()->invoke<void>(object, method);
+  }
 };
 
 } // namespace server {

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/python/setup.py.in
----------------------------------------------------------------------
diff --git a/src/python/setup.py.in b/src/python/setup.py.in
index 47cea7c..02f00ef 100644
--- a/src/python/setup.py.in
+++ b/src/python/setup.py.in
@@ -20,7 +20,7 @@ src_python_dist = os.path.join('src', 'python', 'dist')
 src_python_native = os.path.join('src', 'python', 'native')
 
 leveldb = os.path.join('3rdparty', 'leveldb')
-zookeeper = os.path.join('3rdparty', 'zookeeper-3.3.4', 'src', 'c')
+zookeeper = os.path.join('3rdparty', 'zookeeper-3.4.5', 'src', 'c')
 libprocess = os.path.join('3rdparty', 'libprocess')
 
 # Even though a statically compiled libprocess should include glog,

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/tests/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper.cpp b/src/tests/zookeeper.cpp
index 8462f1f..f5ae23c 100644
--- a/src/tests/zookeeper.cpp
+++ b/src/tests/zookeeper.cpp
@@ -20,7 +20,9 @@
 
 #include <gtest/gtest.h>
 
-#include <queue>
+#include <list>
+#include <string>
+#include <vector>
 
 #include <jvm/jvm.hpp>
 
@@ -29,6 +31,8 @@
 
 #include <stout/check.hpp>
 #include <stout/lambda.hpp>
+#include <stout/path.hpp>
+#include <stout/os.hpp>
 
 #include "common/lock.hpp"
 
@@ -38,6 +42,10 @@
 #include "tests/zookeeper.hpp"
 #include "tests/zookeeper_test_server.hpp"
 
+using std::list;
+using std::string;
+using std::vector;
+
 namespace mesos {
 namespace internal {
 namespace tests {
@@ -48,16 +56,24 @@ const Duration ZooKeeperTest::NO_TIMEOUT = Milliseconds(5000);
 void ZooKeeperTest::SetUpTestCase()
 {
   if (!Jvm::created()) {
-    std::string zkHome = flags.build_dir +
-      "/3rdparty/zookeeper-" ZOOKEEPER_VERSION;
+    string zkHome =
+      path::join(flags.build_dir, "/3rdparty/zookeeper-" ZOOKEEPER_VERSION);
+
+    string classpath = "-Djava.class.path=" +
+      path::join(zkHome, "zookeeper-" ZOOKEEPER_VERSION ".jar");
+
+    // Now add all the libraries in 'lib' too.
+    Try<list<string> > jars = os::glob(path::join(zkHome, "lib", "*.jar"));
 
-    std::string classpath = "-Djava.class.path=" +
-      zkHome + "/zookeeper-" ZOOKEEPER_VERSION ".jar:" +
-      zkHome + "/lib/log4j-1.2.15.jar";
+    CHECK_SOME(jars);
+
+    foreach (const string& jar, jars.get()) {
+      classpath += ":" + jar;
+    }
 
-    LOG(INFO) << "Using classpath setup: " << classpath << std::endl;
+    LOG(INFO) << "Using Java classpath: " << classpath;
 
-    std::vector<std::string> options;
+    vector<string> options;
     options.push_back(classpath);
     Try<Jvm*> jvm = Jvm::create(options);
     CHECK_SOME(jvm);
@@ -103,7 +119,7 @@ void ZooKeeperTest::TestWatcher::process(
     ZooKeeper* zk,
     int type,
     int state,
-    const std::string& path)
+    const string& path)
 {
   Lock lock(&mutex);
   events.push(Event(type, state, path));
@@ -127,13 +143,13 @@ void ZooKeeperTest::TestWatcher::awaitSessionEvent(int state)
 
 static bool isCreated(
     const ZooKeeperTest::TestWatcher::Event& event,
-    const std::string& path)
+    const string& path)
 {
   return event.type == ZOO_CHILD_EVENT && event.path == path;
 }
 
 
-void ZooKeeperTest::TestWatcher::awaitCreated(const std::string& path)
+void ZooKeeperTest::TestWatcher::awaitCreated(const string& path)
 {
   awaitEvent(lambda::bind(&isCreated, lambda::_1, path));
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/tests/zookeeper_test_server.cpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper_test_server.cpp b/src/tests/zookeeper_test_server.cpp
index 62b4e0b..a8c9b1c 100644
--- a/src/tests/zookeeper_test_server.cpp
+++ b/src/tests/zookeeper_test_server.cpp
@@ -30,9 +30,9 @@
 
 #include "tests/zookeeper_test_server.hpp"
 
-using org::apache::zookeeper::persistence::FileTxnSnapLog;
+using org::apache::zookeeper::server::persistence::FileTxnSnapLog;
 
-using org::apache::zookeeper::server::NIOServerCnxn;
+using org::apache::zookeeper::server::NIOServerCnxnFactory;
 using org::apache::zookeeper::server::ZooKeeperServer;
 
 namespace mesos {
@@ -114,32 +114,51 @@ std::string ZooKeeperTestServer::connectString() const
 
 void ZooKeeperTestServer::shutdownNetwork()
 {
-  if (started && connectionFactory && connectionFactory->isAlive()) {
+  if (connectionFactory != NULL && started) {
     connectionFactory->shutdown();
     delete connectionFactory;
     connectionFactory = NULL;
-    LOG(INFO) << "Shutdown ZooKeeperTestServer on port " << port << std::endl;
+    started = false;
+    LOG(INFO) << "Shutdown ZooKeeperTestServer on port " << port;
   }
 }
 
 
 int ZooKeeperTestServer::startNetwork()
 {
-  connectionFactory = new NIOServerCnxn::Factory(
-      java::net::InetSocketAddress(port));
-
-  connectionFactory->startup(*zooKeeperServer);
-
-  if (port == 0) {
-    // We save the ephemeral port so if/when we restart the network
-    // the clients will reconnect to the same server. Note that this
-    // might not actually be kosher because it's possible that another
-    // process could bind to our ephemeral port after we unbind.
-    port = zooKeeperServer->getClientPort();
+  if (!started) {
+    connectionFactory = new NIOServerCnxnFactory();
+
+    // We use '-1' to allow an unlimited number of connections for his
+    // connection factory instance.
+    connectionFactory->configure(java::net::InetSocketAddress(port), -1);
+
+    // It's possible that we are restarting the network, but not the
+    // server. Unfortunately, we can't just invoke 'startup' on the
+    // NIOServerCnxnFactory because of a bug in ZooKeeperServer (see
+    // MESOS-670). We remedy this with a giant hack: by setting the
+    // 'sessionTracker' variable on ZooKeeperServer to null then a new
+    // instance will get created and everything will work out. Until
+    // ZooKeeper provides mechanisms for doing in-memory testing this
+    // hack (or something like it) will need to exist. This hack is
+    // specific to ZooKeeper 3.4.5 and may need to change if up
+    // upgrade ZooKeeper.
+    zooKeeperServer->sessionTracker = Jvm::Null();
+
+    connectionFactory->startup(*zooKeeperServer);
+
+    if (port == 0) {
+      // We save the ephemeral port so if/when we restart the network
+      // the clients will reconnect to the same server. Note that this
+      // might not actually be kosher because it's possible that another
+      // process could bind to our ephemeral port after we unbind.
+      port = zooKeeperServer->getClientPort();
+    }
+
+    LOG(INFO) << "Started ZooKeeperTestServer on port " << port;
+    started = true;
   }
 
-  LOG(INFO) << "Started ZooKeeperTestServer on port " << port;
-  started = true;
   return port;
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bfbc2c3/src/tests/zookeeper_test_server.hpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper_test_server.hpp b/src/tests/zookeeper_test_server.hpp
index e612621..e415ce6 100644
--- a/src/tests/zookeeper_test_server.hpp
+++ b/src/tests/zookeeper_test_server.hpp
@@ -74,7 +74,7 @@ public:
 
 private:
   org::apache::zookeeper::server::ZooKeeperServer* zooKeeperServer;
-  org::apache::zookeeper::server::NIOServerCnxn::Factory* connectionFactory;
+  org::apache::zookeeper::server::NIOServerCnxnFactory* connectionFactory;
 
   int port;
   bool started;


[14/15] git commit: Added --with-cxx11 to Mesos configuration.

Posted by be...@apache.org.
Added --with-cxx11 to Mesos configuration.

When building with clang we assume --with-cxx11. For example:

  CC=/path/to/clang CXX=/path/to/clang++ ../configure

But when building with gcc 4.8 you need to specify C++11:

  CC=/path/to/gcc CXX=/path/to/g++ ../configure --with-cxx11

At this point in time compiling using C++11 with gcc 4.8 on OS X does
not work with Python so it is explicitely disabled.

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


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

Branch: refs/heads/master
Commit: 2dea250c0bea22b547dd3a730ad495f688daef77
Parents: 3cab40a
Author: Benjamin Hindman <be...@gmail.com>
Authored: Mon Dec 30 11:29:32 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:01:11 2014 -0800

----------------------------------------------------------------------
 configure.ac                   |  87 ++++++++++++++++-------
 m4/ax_cxx_compile_stdcxx_11.m4 | 133 ++++++++++++++++++++++++++++++++++++
 2 files changed, 196 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2dea250c/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 18d9730..9f96b7d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,6 +140,11 @@ AC_ARG_WITH([included-zookeeper],
                            appropriate may be necessary)]),
              [], [with_included_zookeeper=yes])
 
+AC_ARG_WITH([cxx11],
+            AS_HELP_STRING([--with-cxx11],
+                           [builds Mesos using C++11]),
+            [], [with_cxx11=no])
+
 # TODO(benh): Support --without-included-protobuf,
 # --without-included-glog, etc. Doing this for protobuf is
 # considerably more tricky because we need to make sure that 'protoc'
@@ -170,31 +175,24 @@ case "${target_os}" in
     echo ===========================================================
     OS_NAME=darwin
     ;;
-  solaris*)
-    echo ===========================================================
-    echo Setting up build environment for ${target_cpu} ${target_os}
-    echo ===========================================================
-    OS_NAME=solaris
-    CC=gcc-4.3.2
-    CXX=g++-4.3.2
-    CFLAGS="$CFLAGS -pthreads -march=i586"
-    CXXFLAGS="$CXXFLAGS -pthreads -march=i586"
-    LIBS="$LIBS -lsocket -lnsl -lproject -lproc"
-    ;;
   *)
     AC_MSG_ERROR("Mesos is currently unsupported on your platform.")
-  esac
+esac
 
 
 # Used for conditionally including source files.
 AM_CONDITIONAL([OS_LINUX], [test "x$OS_NAME" = "xlinux"])
 
 
-# Checks for gcc toolchain (we rely on some atomic builtins for now).
+# Default to gcc toolchain (we rely on some atomic builtins for now,
+# that are also present with clang).
 AC_PROG_CXX([g++])
 AC_PROG_CC([gcc])
 
-# Check the version of gcc and add any flags as appropriate.
+
+# Check the version of gcc and add any flags as appropriate. Note that
+# '-dumpversion' works for clang as well but as of clang 3.3 it
+# reports version 4.2.1 (for gcc backwards compatibility).
 GCC_VERSION="`${CC} -dumpversion`"
 test $? = 0 || AC_MSG_ERROR([failed to determine version of gcc])
 case  "${GCC_VERSION}" in
@@ -220,6 +218,37 @@ case  "${GCC_VERSION}" in
 esac
 
 
+# Check if we should try and enable optimizations.
+if test "x$enable_optimize" = "xyes"; then
+  # For now, we only turn on optimizations for gcc.
+  if test "x$GCC" = "xyes"; then
+    CXXFLAGS="$CXXFLAGS -g2 -O2"
+  fi
+fi
+
+
+# Check if we're using clang.
+AC_MSG_CHECKING([if compiling with clang])
+
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([], [[
+#ifndef __clang__
+       not clang
+#endif
+]])],
+[CLANG=yes], [CLANG=no])
+AC_LANG_POP([C++])
+
+AC_MSG_RESULT([$CLANG])
+AC_SUBST([CLANG])
+
+# Force C++11 if we're using clang.
+if test "x$CLANG" = "xyes"; then
+  with_cxx11=yes
+fi
+
+
 # Check for pthreads (uses m4/acx_pthread.m4).
 ACX_PTHREAD([], [AC_MSG_ERROR([failed to find pthreads])])
 
@@ -555,15 +584,6 @@ fi
 AM_CONDITIONAL([HAS_PYTHON], [test "x$has_python" = "xyes"])
 
 
-# Check if we should try and enable optimizations.
-if test "x$enable_optimize" = "xyes"; then
-  # For now, we only turn on optimizations for gcc.
-  if test "x$GCC" = "xyes"; then
-    CXXFLAGS="$CXXFLAGS -g2 -O2"
-  fi
-fi
-
-
 # Check if we should/can build with libcurl.
 if test "x$with_curl" = "xyes"; then
   AC_CHECK_LIB([z], [gzread], [],
@@ -600,7 +620,6 @@ if test "x$with_curl" = "xyes"; then
   and task resources cannot be downloaded over http.
   -------------------------------------------------------------------
   ])])
-
 fi
 
 
@@ -608,6 +627,24 @@ AM_CONDITIONAL([WITH_INCLUDED_ZOOKEEPER],
                [test "x$with_included_zookeeper" = "xyes"])
 
 
+# Check if we should/can build with C++11.
+if test "x$with_cxx11" = "xyes"; then
+  AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
+
+   # If we're using clang, we need to pass -stdlib=libc++ too.
+  if test "x$CLANG" = "xyes"; then
+    CXXFLAGS="$CXXFLAGS -stdlib=libc++"
+  fi
+
+  # Force gtest to use it's own tuple implementation since 'tr1/tuple'
+  # might not exist (for example, if building with clang).
+  CXXFLAGS="-DGTEST_USE_OWN_TR1_TUPLE=1 $CXXFLAGS"
+
+  # Also pass the flags to 3rdparty libraries.
+  CONFIGURE_ARGS="$CONFIGURE_ARGS CXXFLAGS='$CXXFLAGS'"
+fi
+
+
 # TODO(benh): Also check for md5 support so we can use the CRAM-MD5
 # mechanism. We can likely do a AC_CHECK_LIB looking for a particular
 # function only provided if md5 support is present.
@@ -618,6 +655,8 @@ We need libsasl2 for authentication!
 -------------------------------------------------------------------
 ])])
 
+
 AM_CONDITIONAL([GIT_REPO], [test -d ${srcdir}"/.git"])
 
+
 AC_OUTPUT

http://git-wip-us.apache.org/repos/asf/mesos/blob/2dea250c/m4/ax_cxx_compile_stdcxx_11.m4
----------------------------------------------------------------------
diff --git a/m4/ax_cxx_compile_stdcxx_11.m4 b/m4/ax_cxx_compile_stdcxx_11.m4
new file mode 100644
index 0000000..07b298f
--- /dev/null
+++ b/m4/ax_cxx_compile_stdcxx_11.m4
@@ -0,0 +1,133 @@
+# ============================================================================
+#  http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+#   AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
+#
+# DESCRIPTION
+#
+#   Check for baseline language coverage in the compiler for the C++11
+#   standard; if necessary, add switches to CXXFLAGS to enable support.
+#
+#   The first argument, if specified, indicates whether you insist on an
+#   extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
+#   -std=c++11).  If neither is specified, you get whatever works, with
+#   preference for an extended mode.
+#
+#   The second argument, if specified 'mandatory' or if left unspecified,
+#   indicates that baseline C++11 support is required and that the macro
+#   should error out if no mode with that support is found.  If specified
+#   'optional', then configuration proceeds regardless, after defining
+#   HAVE_CXX11 if and only if a supporting mode is found.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Benjamin Kosnik <bk...@redhat.com>
+#   Copyright (c) 2012 Zack Weinberg <za...@panix.com>
+#   Copyright (c) 2013 Roy Stogner <ro...@ices.utexas.edu>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 3
+
+m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
+  template <typename T>
+    struct check
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+    typedef check<check<bool>> right_angle_brackets;
+
+    int a;
+    decltype(a) b;
+
+    typedef check<int> check_type;
+    check_type c;
+    check_type&& cr = static_cast<check_type&&>(c);
+
+    auto d = a;
+])
+
+AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [
+  m4_if([$1], [], [],
+        [$1], [ext], [],
+        [$1], [noext], [],
+        [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])
+  m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
+        [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
+        [$2], [optional], [ax_cxx_compile_cxx11_required=false],
+        [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
+  AC_LANG_PUSH([C++])
+  ac_success=no
+  AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
+  ax_cv_cxx_compile_cxx11,
+  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+    [ax_cv_cxx_compile_cxx11=yes],
+    [ax_cv_cxx_compile_cxx11=no])])
+  if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+    ac_success=yes
+  fi
+
+  m4_if([$1], [noext], [], [
+  if test x$ac_success = xno; then
+    for switch in -std=gnu++11 -std=gnu++0x; do
+      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+                     $cachevar,
+        [ac_save_CXXFLAGS="$CXXFLAGS"
+         CXXFLAGS="$CXXFLAGS $switch"
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+          [eval $cachevar=yes],
+          [eval $cachevar=no])
+         CXXFLAGS="$ac_save_CXXFLAGS"])
+      if eval test x\$$cachevar = xyes; then
+        CXXFLAGS="$CXXFLAGS $switch"
+        ac_success=yes
+        break
+      fi
+    done
+  fi])
+
+  m4_if([$1], [ext], [], [
+  if test x$ac_success = xno; then
+    for switch in -std=c++11 -std=c++0x; do
+      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+                     $cachevar,
+        [ac_save_CXXFLAGS="$CXXFLAGS"
+         CXXFLAGS="$CXXFLAGS $switch"
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+          [eval $cachevar=yes],
+          [eval $cachevar=no])
+         CXXFLAGS="$ac_save_CXXFLAGS"])
+      if eval test x\$$cachevar = xyes; then
+        CXXFLAGS="$CXXFLAGS $switch"
+        ac_success=yes
+        break
+      fi
+    done
+  fi])
+  AC_LANG_POP([C++])
+  if test x$ax_cxx_compile_cxx11_required = xtrue; then
+    if test x$ac_success = xno; then
+      AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
+    fi
+  else
+    if test x$ac_success = xno; then
+      HAVE_CXX11=0
+      AC_MSG_NOTICE([No compiler with C++11 support was found])
+    else
+      HAVE_CXX11=1
+      AC_DEFINE(HAVE_CXX11,1,
+                [define if the compiler supports basic C++11 syntax])
+    fi
+
+    AC_SUBST(HAVE_CXX11)
+  fi
+])


[10/15] git commit: Fixed protobuf::read bug exposed when running Mesos compiled by clang.

Posted by be...@apache.org.
Fixed protobuf::read bug exposed when running Mesos compiled by clang.

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


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

Branch: refs/heads/master
Commit: c2bf245940fede312db19d9596a532cb164b0005
Parents: 95eda5a
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:52:37 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:00:40 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c2bf2459/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
index 3fa7fe6..abbb537 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
@@ -124,9 +124,13 @@ inline Result<T> read(int fd, bool ignorePartial = false)
   }
 
   // Parse the protobuf from the string.
+  // NOTE: We need to capture a const reference to the data because it
+  // must outlive the creation of ArrayInputStream.
+  const std::string& data = result.get();
+
   T message;
   google::protobuf::io::ArrayInputStream stream(
-      result.get().data(), result.get().size());
+      data.data(), data.size());
 
   if (!message.ParseFromZeroCopyStream(&stream)) {
     // Restore the offset to before the size read.


[13/15] git commit: Added --with-cxx11 to libprocess configuration.

Posted by be...@apache.org.
Added --with-cxx11 to libprocess configuration.

When building with clang we assume --with-cxx11. For example:

  CC=/path/to/clang CXX=/path/to/clang++ ../configure

But when building with gcc 4.8 you need to specify C++11:

  CC=/path/to/gcc CXX=/path/to/g++ ../configure --with-cxx11

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


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

Branch: refs/heads/master
Commit: 3cab40aa00bb13a394f536c75a2b4de2c26b0614
Parents: a2792e6
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:53:43 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:01:11 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/configure.ac                |  68 ++++++++--
 .../libprocess/m4/ax_cxx_compile_stdcxx_11.m4   | 133 +++++++++++++++++++
 2 files changed, 193 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3cab40aa/3rdparty/libprocess/configure.ac
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/configure.ac b/3rdparty/libprocess/configure.ac
index d3b86a3..e461590 100644
--- a/3rdparty/libprocess/configure.ac
+++ b/3rdparty/libprocess/configure.ac
@@ -69,6 +69,12 @@ AC_ARG_WITH([zlib],
                             will be far less responsive; not recommended]),
             [], [with_zlib=yes])
 
+AC_ARG_WITH([cxx11],
+            AS_HELP_STRING([--with-cxx11],
+                           [builds libprocess using C++11]),
+            [], [with_cxx11=no])
+
+
 # Do some OS specific setup.
 case "${target_os}" in
   linux*)
@@ -79,13 +85,17 @@ case "${target_os}" in
     ;;
 esac
 
-# Checks for gcc toolchain (we rely on some atomic builtins for now).
+
+# Used for conditionally building source files (e.g., only want to
+# build stout/tests/proc_tests.cpp on Linux).
+AM_CONDITIONAL([OS_LINUX], [test "x$OS_NAME" = "xlinux"])
+
+
+# Default to gcc toolchain (we rely on some atomic builtins for now,
+# that are also present with clang).
 AC_PROG_CXX([g++])
 AC_PROG_CC([gcc])
 
-# Check for pthreads (uses m4/acx_pthread.m4).
-ACX_PTHREAD([], [AC_MSG_ERROR([failed to find pthreads])])
-
 
 # Check if we should try and enable optimizations.
 if test "x$enable_optimize" = "xyes"; then
@@ -96,6 +106,35 @@ if test "x$enable_optimize" = "xyes"; then
 fi
 
 
+# Check if clang was provided instead.
+AC_MSG_CHECKING([if compiling with clang])
+
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([], [[
+#ifndef __clang__
+       not clang
+#endif
+]])],
+[CLANG=yes], [CLANG=no])
+AC_LANG_POP([C++])
+
+AC_MSG_RESULT([$CLANG])
+AC_SUBST([CLANG])
+
+# Force C++11 if we're using clang.
+if test "x$CLANG" = "xyes"; then
+  with_cxx11=yes
+fi
+
+
+# Check for pthreads (uses m4/acx_pthread.m4).
+ACX_PTHREAD([], [AC_MSG_ERROR([failed to find pthreads])])
+
+
+AM_CONDITIONAL([HAS_GPERFTOOLS], [test "x$gperftools" = "xyes"])
+
+
 # Check if we should/can build with libz.
 if test "x$with_zlib" = "xyes"; then
   AC_CHECK_LIB([z], [deflate, gzread, gzwrite, inflate], [],
@@ -108,10 +147,23 @@ if test "x$with_zlib" = "xyes"; then
   ])])
 fi
 
-AM_CONDITIONAL([HAS_GPERFTOOLS], [test "x$gperftools" = "xyes"])
 
-# Used for conditionally building source files (e.g., only want to
-# build stout/tests/proc_tests.cpp on Linux).
-AM_CONDITIONAL([OS_LINUX], [test "x$OS_NAME" = "xlinux"])
+# Check if we should/can build with C++11.
+if test "x$with_cxx11" = "xyes"; then
+  AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
+
+  # If we're using clang, we need to pass -stdlib=libc++ too.
+  if test "x$CLANG" = "xyes"; then
+    CXXFLAGS="$CXXFLAGS -stdlib=libc++"
+  fi
+
+  # Force gtest to use it's own tuple implementation since 'tr1/tuple'
+  # might not exist (for example, if building with clang).
+  CXXFLAGS="-DGTEST_USE_OWN_TR1_TUPLE=1 $CXXFLAGS"
+
+  # Also pass the flags to 3rdparty libraries.
+  CONFIGURE_ARGS="$CONFIGURE_ARGS CXXFLAGS='$CXXFLAGS'"
+fi
+
 
 AC_OUTPUT

http://git-wip-us.apache.org/repos/asf/mesos/blob/3cab40aa/3rdparty/libprocess/m4/ax_cxx_compile_stdcxx_11.m4
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/m4/ax_cxx_compile_stdcxx_11.m4 b/3rdparty/libprocess/m4/ax_cxx_compile_stdcxx_11.m4
new file mode 100644
index 0000000..07b298f
--- /dev/null
+++ b/3rdparty/libprocess/m4/ax_cxx_compile_stdcxx_11.m4
@@ -0,0 +1,133 @@
+# ============================================================================
+#  http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+#   AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
+#
+# DESCRIPTION
+#
+#   Check for baseline language coverage in the compiler for the C++11
+#   standard; if necessary, add switches to CXXFLAGS to enable support.
+#
+#   The first argument, if specified, indicates whether you insist on an
+#   extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
+#   -std=c++11).  If neither is specified, you get whatever works, with
+#   preference for an extended mode.
+#
+#   The second argument, if specified 'mandatory' or if left unspecified,
+#   indicates that baseline C++11 support is required and that the macro
+#   should error out if no mode with that support is found.  If specified
+#   'optional', then configuration proceeds regardless, after defining
+#   HAVE_CXX11 if and only if a supporting mode is found.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Benjamin Kosnik <bk...@redhat.com>
+#   Copyright (c) 2012 Zack Weinberg <za...@panix.com>
+#   Copyright (c) 2013 Roy Stogner <ro...@ices.utexas.edu>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 3
+
+m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
+  template <typename T>
+    struct check
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+    typedef check<check<bool>> right_angle_brackets;
+
+    int a;
+    decltype(a) b;
+
+    typedef check<int> check_type;
+    check_type c;
+    check_type&& cr = static_cast<check_type&&>(c);
+
+    auto d = a;
+])
+
+AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [
+  m4_if([$1], [], [],
+        [$1], [ext], [],
+        [$1], [noext], [],
+        [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])
+  m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
+        [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
+        [$2], [optional], [ax_cxx_compile_cxx11_required=false],
+        [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
+  AC_LANG_PUSH([C++])
+  ac_success=no
+  AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
+  ax_cv_cxx_compile_cxx11,
+  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+    [ax_cv_cxx_compile_cxx11=yes],
+    [ax_cv_cxx_compile_cxx11=no])])
+  if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+    ac_success=yes
+  fi
+
+  m4_if([$1], [noext], [], [
+  if test x$ac_success = xno; then
+    for switch in -std=gnu++11 -std=gnu++0x; do
+      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+                     $cachevar,
+        [ac_save_CXXFLAGS="$CXXFLAGS"
+         CXXFLAGS="$CXXFLAGS $switch"
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+          [eval $cachevar=yes],
+          [eval $cachevar=no])
+         CXXFLAGS="$ac_save_CXXFLAGS"])
+      if eval test x\$$cachevar = xyes; then
+        CXXFLAGS="$CXXFLAGS $switch"
+        ac_success=yes
+        break
+      fi
+    done
+  fi])
+
+  m4_if([$1], [ext], [], [
+  if test x$ac_success = xno; then
+    for switch in -std=c++11 -std=c++0x; do
+      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+                     $cachevar,
+        [ac_save_CXXFLAGS="$CXXFLAGS"
+         CXXFLAGS="$CXXFLAGS $switch"
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+          [eval $cachevar=yes],
+          [eval $cachevar=no])
+         CXXFLAGS="$ac_save_CXXFLAGS"])
+      if eval test x\$$cachevar = xyes; then
+        CXXFLAGS="$CXXFLAGS $switch"
+        ac_success=yes
+        break
+      fi
+    done
+  fi])
+  AC_LANG_POP([C++])
+  if test x$ax_cxx_compile_cxx11_required = xtrue; then
+    if test x$ac_success = xno; then
+      AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
+    fi
+  else
+    if test x$ac_success = xno; then
+      HAVE_CXX11=0
+      AC_MSG_NOTICE([No compiler with C++11 support was found])
+    else
+      HAVE_CXX11=1
+      AC_DEFINE(HAVE_CXX11,1,
+                [define if the compiler supports basic C++11 syntax])
+    fi
+
+    AC_SUBST(HAVE_CXX11)
+  fi
+])


[12/15] git commit: Refactorings necessary for getting clang to compile C++11 libprocess.

Posted by be...@apache.org.
Refactorings necessary for getting clang to compile C++11 libprocess.

A test was also added that provides all possible examples of using
std::bind and lambda's with process::defer, Future::on* (Ready,
Failed, etc) and Future::then.

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


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

Branch: refs/heads/master
Commit: 02bd8488fbcc647b0c0ac46bf2adab956301f8d8
Parents: c2bf245
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:55:24 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:01:09 2014 -0800

----------------------------------------------------------------------
 .../libprocess/include/process/c++11/defer.hpp  |  36 ++-
 .../include/process/c++11/deferred.hpp          |  43 ++-
 .../include/process/c++11/executor.hpp          |   4 +-
 3rdparty/libprocess/include/process/future.hpp  | 289 ++++++++++++++++---
 3rdparty/libprocess/src/tests/process_tests.cpp | 146 ++++++++++
 5 files changed, 453 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/02bd8488/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
index 27b0643..de041ad 100644
--- a/3rdparty/libprocess/include/process/c++11/defer.hpp
+++ b/3rdparty/libprocess/include/process/c++11/defer.hpp
@@ -50,7 +50,10 @@ Deferred<void(void)> defer(
 
 // 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.
+// 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),                                 \
@@ -58,12 +61,13 @@ Deferred<void(void)> defer(
   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))>(), ENUM_PARAMS(N, a)))> \
+    -> _Deferred<decltype(std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::function<void(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> \
   {                                                                     \
-    return std::bind(std::function<void(ENUM_PARAMS(N, P))>(            \
+    std::function<void(ENUM_PARAMS(N, P))> f(                           \
         [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
           dispatch(pid, method, ENUM_PARAMS(N, p));                     \
-        }), ENUM_PARAMS(N, a));                                         \
+        });                                                             \
+    return std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); \
   }                                                                     \
                                                                         \
   template <typename T,                                                 \
@@ -125,12 +129,13 @@ defer(const Process<T>* process, Future<R> (T::*method)(void))
   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))>(), ENUM_PARAMS(N, 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)))> \
   {                                                                     \
-    return std::bind(std::function<Future<R>(ENUM_PARAMS(N, P))>(       \
+    std::function<Future<R>(ENUM_PARAMS(N, P))> f(                      \
         [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
           return dispatch(pid, method, ENUM_PARAMS(N, p));              \
-        }), ENUM_PARAMS(N, a));                                         \
+        });                                                             \
+    return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); \
   }                                                                     \
                                                                         \
   template <typename R,                                                 \
@@ -194,12 +199,13 @@ defer(const Process<T>* process, R (T::*method)(void))
   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))>(), ENUM_PARAMS(N, 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)))> \
   {                                                                     \
-    return std::bind(std::function<Future<R>(ENUM_PARAMS(N, P))>(       \
+    std::function<Future<R>(ENUM_PARAMS(N, P))> f(                      \
         [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
           return dispatch(pid, method, ENUM_PARAMS(N, p));              \
-        }), ENUM_PARAMS(N, a));                                         \
+        });                                                             \
+    return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); \
   }                                                                     \
                                                                         \
   template <typename R,                                                 \
@@ -235,20 +241,20 @@ defer(const Process<T>* process, R (T::*method)(void))
 // Now we define defer calls for functors (with and without a PID):
 
 template <typename F>
-_Deferred<F> defer(const UPID& pid, F f)
+_Deferred<F> defer(const UPID& pid, F&& f)
 {
-  return _Deferred<F>(pid, f);
+  return _Deferred<F>(pid, std::forward<F>(f));
 }
 
 
 template <typename F>
-_Deferred<F> defer(F f)
+_Deferred<F> defer(F&& f)
 {
   if (__process__ != NULL) {
-    return defer(__process__->self(), f);
+    return defer(__process__->self(), std::forward<F>(f));
   }
 
-  return __executor__->defer(f);
+  return __executor__->defer(std::forward<F>(f));
 }
 
 } // namespace process {

http://git-wip-us.apache.org/repos/asf/mesos/blob/02bd8488/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
index 06e67cf..57a3df5 100644
--- a/3rdparty/libprocess/include/process/c++11/deferred.hpp
+++ b/3rdparty/libprocess/include/process/c++11/deferred.hpp
@@ -4,19 +4,12 @@
 #include <functional>
 
 #include <process/dispatch.hpp>
-#include <process/future.hpp>
 #include <process/pid.hpp>
 
 #include <stout/preprocessor.hpp>
 
 namespace process {
 
-// Forward declarations (removing these produces cryptic compiler
-// errors even though we are just using them to declare friends).
-class Executor;
-template <typename G> struct _Deferred;
-
-
 // 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).
@@ -46,11 +39,28 @@ private:
 };
 
 
+// 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);
     }
@@ -113,6 +123,12 @@ struct _Deferred
         });
   }
 
+  // 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                   \
@@ -201,10 +217,7 @@ private:
   friend class Executor;
 
   template <typename G>
-  friend _Deferred<G> defer(const UPID& pid, G g);
-
-  template <typename G>
-  friend _Deferred<G> defer(G g);
+  friend _Deferred<G> defer(const UPID& pid, G&& g);
 
 #define TEMPLATE(Z, N, DATA)                                            \
   template <typename T,                                                 \
@@ -213,7 +226,7 @@ private:
   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))>(), ENUM_PARAMS(N, a)))>;
+    -> _Deferred<decltype(std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::function<void(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))>;
 
   REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
 #undef TEMPLATE
@@ -226,7 +239,7 @@ private:
   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))>(), ENUM_PARAMS(N, 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)))>;
 
   REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
 #undef TEMPLATE
@@ -239,12 +252,12 @@ private:
   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))>(), ENUM_PARAMS(N, 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)))>;
 
   REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
 #undef TEMPLATE
 
-  _Deferred(UPID pid, F f) : pid(pid), f(f) {}
+  _Deferred(const UPID& pid, F f) : pid(pid), f(f) {}
   _Deferred(F f) : f(f) {}
 
   Option<UPID> pid;

http://git-wip-us.apache.org/repos/asf/mesos/blob/02bd8488/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
index c6c9032..157a1d2 100644
--- a/3rdparty/libprocess/include/process/c++11/executor.hpp
+++ b/3rdparty/libprocess/include/process/c++11/executor.hpp
@@ -39,9 +39,9 @@ public:
   }
 
   template <typename F>
-  _Deferred<F> defer(F f)
+  _Deferred<F> defer(F&& f)
   {
-    return _Deferred<F>(process.self(), f);
+    return _Deferred<F>(process.self(), std::forward<F>(f));
   }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/02bd8488/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp
index 02e89bd..2a5f124 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -105,46 +105,143 @@ public:
   typedef lambda::function<void(void)> DiscardedCallback;
   typedef lambda::function<void(const Future<T>&)> AnyCallback;
 
+#if __cplusplus >= 201103L
   // Installs callbacks for the specified events and returns a const
   // reference to 'this' in order to easily support chaining.
-  const Future<T>& onReady(const ReadyCallback& callback) const;
-  const Future<T>& onFailed(const FailedCallback& callback) const;
-  const Future<T>& onDiscarded(const DiscardedCallback& callback) const;
-  const Future<T>& onAny(const AnyCallback& callback) const;
+  const Future<T>& onReady(ReadyCallback&& callback) const;
+  const Future<T>& onFailed(FailedCallback&& callback) const;
+  const Future<T>& onDiscarded(DiscardedCallback&& callback) const;
+  const Future<T>& onAny(AnyCallback&& callback) const;
+
+  // TODO(benh): Add onReady, onFailed, onAny for _Deferred<F> where F
+  // is not expected.
 
-#if __cplusplus >= 201103L
   template <typename F>
-  const Future<T>& onReady(const _Deferred<F>& deferred) const
+  const Future<T>& onReady(_Deferred<F>&& deferred) const
   {
     return onReady(std::function<void(const T&)>(deferred));
   }
 
   template <typename F>
-  const Future<T>& onFailed(const _Deferred<F>& deferred) const
+  const Future<T>& onFailed(_Deferred<F>&& deferred) const
   {
     return onFailed(std::function<void(const std::string&)>(deferred));
   }
 
   template <typename F>
-  const Future<T>& onAny(const _Deferred<F>& deferred) const
+  const Future<T>& onDiscarded(_Deferred<F>&& deferred) const
+  {
+    return onDiscarded(std::function<void()>(deferred));
+  }
+
+  template <typename F>
+  const Future<T>& onAny(_Deferred<F>&& deferred) const
   {
     return onAny(std::function<void(const Future<T>&)>(deferred));
   }
 
-  const Future<T>& onReady(const Deferred<void(void)>& deferred) const
+private:
+  // We use the 'Prefer' and 'LessPrefer' structs as a way to prefer
+  // one function over the other when doing SFINAE for the 'onReady',
+  // 'onFailed', 'onAny', and 'then' functions. In each of these cases
+  // we prefer calling the version of the functor that takes in an
+  // argument (i.e., 'const T&' for 'onReady' and 'then' and 'const
+  // std::string&' for 'onFailed'), but we allow functors that don't
+  // care about the argument. We don't need to do this for
+  // 'onDiscarded' because it doesn't take an argument.
+  struct LessPrefer {};
+  struct Prefer : LessPrefer {};
+
+  template <typename F, typename = typename std::result_of<F(const T&)>::type>
+  const Future<T>& onReady(F&& f, Prefer) const
+  {
+    return onReady(std::function<void(const T&)>(
+        [=] (const T& t) mutable {
+          f(t);
+        }));
+  }
+
+  template <typename F, typename = typename std::result_of<F()>::type>
+  const Future<T>& onReady(F&& f, LessPrefer) const
+  {
+    return onReady(std::function<void(const T&)>(
+        [=] (const T&) mutable {
+          f();
+        }));
+  }
+
+  template <typename F, typename = typename std::result_of<F(const std::string&)>::type>
+  const Future<T>& onFailed(F&& f, Prefer) const
+  {
+    return onFailed(std::function<void(const std::string&)>(
+        [=] (const std::string& message) mutable {
+          f(message);
+        }));
+  }
+
+  template <typename F, typename = typename std::result_of<F()>::type>
+  const Future<T>& onFailed(F&& f, LessPrefer) const
+  {
+    return onFailed(std::function<void(const std::string&)>(
+        [=] (const std::string&) mutable {
+          f();
+        }));
+  }
+
+  template <typename F, typename = typename std::result_of<F(const Future<T>&)>::type>
+  const Future<T>& onAny(F&& f, Prefer) const
+  {
+    return onAny(std::function<void(const Future<T>&)>(
+        [=] (const Future<T>& future) {
+          f(future);
+        }));
+  }
+
+  template <typename F, typename = typename std::result_of<F()>::type>
+  const Future<T>& onAny(F&& f, LessPrefer) const
+  {
+    return onAny(std::function<void(const Future<T>&)>(
+        [=] (const Future<T>&) mutable {
+          f();
+        }));
+  }
+
+public:
+  template <typename F>
+  const Future<T>& onReady(F&& f) const
+  {
+    return onReady(std::forward<F>(f), Prefer());
+  }
+
+  template <typename F>
+  const Future<T>& onFailed(F&& f) const
   {
-    return onReady(std::function<void(const T&)>(lambda::bind(deferred)));
+    return onFailed(std::forward<F>(f), Prefer());
   }
 
-  const Future<T>& onFailed(const Deferred<void(void)>& deferred) const
+  template <typename F>
+  const Future<T>& onDiscarded(F&& f) const
   {
-    return onFailed(std::function<void(const std::string&)>(lambda::bind(deferred)));
+    return onDiscarded(std::function<void()>(
+        [=] () mutable {
+          f();
+        }));
   }
 
-  const Future<T>& onAny(const Deferred<void(void)>& deferred) const
+  template <typename F>
+  const Future<T>& onAny(F&& f) const
   {
-    return onAny(std::function<void(const Future<T>&)>(lambda::bind(deferred)));
+    return onAny(std::forward<F>(f), Prefer());
   }
+
+#else // __cplusplus >= 201103L
+
+  // Installs callbacks for the specified events and returns a const
+  // reference to 'this' in order to easily support chaining.
+  const Future<T>& onReady(const ReadyCallback& callback) const;
+  const Future<T>& onFailed(const FailedCallback& callback) const;
+  const Future<T>& onDiscarded(const DiscardedCallback& callback) const;
+  const Future<T>& onAny(const AnyCallback& callback) const;
 #endif // __cplusplus >= 201103L
 
   // Installs callbacks that get executed when this future is ready
@@ -157,32 +254,51 @@ public:
   Future<X> then(const lambda::function<X(const T&)>& f) const;
 
   template <typename X>
-  Future<X> then(const lambda::function<Future<X>(void)>& f) const
+  Future<X> then(const lambda::function<Future<X>()>& f) const
   {
     return then(lambda::function<Future<X>(const T&)>(lambda::bind(f)));
   }
 
   template <typename X>
-  Future<X> then(const lambda::function<X(void)>& f) const
+  Future<X> then(const lambda::function<X()>& f) const
   {
     return then(lambda::function<X(const T&)>(lambda::bind(f)));
   }
 
 #if __cplusplus >= 201103L
-  template <typename F>
-  typename internal::wrap<typename std::result_of<F(const T&)>::type>::Type
-  then(F f) const
+private:
+  template <typename F, typename X = typename internal::unwrap<typename std::result_of<F(const T&)>::type>::type>
+  Future<X> then(_Deferred<F>&& f, Prefer) const
+  {
+    // note the then<X> is necessary to not have an infinite loop with
+    // then(F&& f)
+    return then<X>(std::function<Future<X>(const T&)>(f));
+  }
+
+  template <typename F, typename X = typename internal::unwrap<typename std::result_of<F()>::type>::type>
+  Future<X> then(_Deferred<F>&& f, LessPrefer) const
+  {
+    return then<X>(std::function<Future<X>()>(f));
+  }
+
+  template <typename F, typename X = typename internal::unwrap<typename std::result_of<F(const T&)>::type>::type>
+  Future<X> then(F&& f, Prefer) const
   {
-    typedef typename std::result_of<F(const T&)>::type R;
-    return then(std::function<R(const T&)>(f));
+    return then<X>(std::function<Future<X>(const T&)>(f));
   }
 
+  template <typename F, typename X = typename internal::unwrap<typename std::result_of<F()>::type>::type>
+  Future<X> then(F&& f, LessPrefer) const
+  {
+    return then<X>(std::function<Future<X>()>(f));
+  }
+
+public:
   template <typename F>
-  typename internal::wrap<typename std::result_of<F(const T&)>::type>::Type
-  then(const _Deferred<F>& deferred) const
+  auto then(F&& f) const
+    -> decltype(this->then(std::forward<F>(f), Prefer()))
   {
-    typedef typename std::result_of<F(const T&)>::type R;
-    return then(std::function<R(const T&)>(deferred));
+    return then(std::forward<F>(f), Prefer());
   }
 
 #else // __cplusplus >= 201103L
@@ -507,28 +623,28 @@ namespace internal {
 template <typename T>
 struct wrap
 {
-  typedef Future<T> Type;
+  typedef Future<T> type;
 };
 
 
 template <typename X>
 struct wrap<Future<X> >
 {
-  typedef Future<X> Type;
+  typedef Future<X> type;
 };
 
 
 template <typename T>
 struct unwrap
 {
-  typedef T Type;
+  typedef T type;
 };
 
 
 template <typename X>
 struct unwrap<Future<X> >
 {
-  typedef X Type;
+  typedef X type;
 };
 
 
@@ -576,8 +692,17 @@ Future<Future<T> > select(const std::set<Future<T> >& futures)
   memory::shared_ptr<Promise<Future<T> > > promise(
       new Promise<Future<T> >());
 
-  Future<Future<T> > future = promise->future();
-
+#if __cplusplus >= 201103L
+  typename std::set<Future<T>>::iterator iterator;
+  for (iterator = futures.begin(); iterator != futures.end(); ++iterator) {
+    // NOTE: We can't use std::bind with a std::function with Clang
+    // like we do below (see
+    // http://stackoverflow.com/questions/20097616/stdbind-to-a-stdfunction-crashes-with-clang).
+    (*iterator).onAny([=] (const Future<T>& future) {
+      internal::select(future, promise);
+    });
+  }
+#else // __cplusplus >= 201103L
   lambda::function<void(const Future<T>&)> select =
     lambda::bind(&internal::select<T>, lambda::_1, promise);
 
@@ -585,8 +710,9 @@ Future<Future<T> > select(const std::set<Future<T> >& futures)
   for (iterator = futures.begin(); iterator != futures.end(); ++iterator) {
     (*iterator).onAny(lambda::bind(select, lambda::_1));
   }
+#endif // __cplusplus >= 201103L
 
-  return future;
+  return promise->future();
 }
 
 
@@ -839,6 +965,103 @@ std::string Future<T>::failure() const
 }
 
 
+#if __cplusplus >= 201103L
+template <typename T>
+const Future<T>& Future<T>::onReady(ReadyCallback&& callback) const
+{
+  bool run = false;
+
+  internal::acquire(&data->lock);
+  {
+    if (data->state == READY) {
+      run = true;
+    } else if (data->state == PENDING) {
+      data->onReadyCallbacks.push(std::move(callback));
+    }
+  }
+  internal::release(&data->lock);
+
+  // TODO(*): Invoke callback in another execution context.
+  if (run) {
+    callback(*data->t);
+  }
+
+  return *this;
+}
+
+
+template <typename T>
+const Future<T>& Future<T>::onFailed(FailedCallback&& callback) const
+{
+  bool run = false;
+
+  internal::acquire(&data->lock);
+  {
+    if (data->state == FAILED) {
+      run = true;
+    } else if (data->state == PENDING) {
+      data->onFailedCallbacks.push(std::move(callback));
+    }
+  }
+  internal::release(&data->lock);
+
+  // TODO(*): Invoke callback in another execution context.
+  if (run) {
+    callback(*data->message);
+  }
+
+  return *this;
+}
+
+
+template <typename T>
+const Future<T>& Future<T>::onDiscarded(DiscardedCallback&& callback) const
+{
+  bool run = false;
+
+  internal::acquire(&data->lock);
+  {
+    if (data->state == DISCARDED) {
+      run = true;
+    } else if (data->state == PENDING) {
+      data->onDiscardedCallbacks.push(std::move(callback));
+    }
+  }
+  internal::release(&data->lock);
+
+  // TODO(*): Invoke callback in another execution context.
+  if (run) {
+    callback();
+  }
+
+  return *this;
+}
+
+
+template <typename T>
+const Future<T>& Future<T>::onAny(AnyCallback&& callback) const
+{
+  bool run = false;
+
+  internal::acquire(&data->lock);
+  {
+    if (data->state != PENDING) {
+      run = true;
+    } else if (data->state == PENDING) {
+      data->onAnyCallbacks.push(std::move(callback));
+    }
+  }
+  internal::release(&data->lock);
+
+  // TODO(*): Invoke callback in another execution context.
+  if (run) {
+    callback(*this);
+  }
+
+  return *this;
+}
+
+#else // __cplusplus >= 201103L
 template <typename T>
 const Future<T>& Future<T>::onReady(const ReadyCallback& callback) const
 {
@@ -934,7 +1157,7 @@ const Future<T>& Future<T>::onAny(const AnyCallback& callback) const
 
   return *this;
 }
-
+#endif // __cplusplus >= 201103L
 
 namespace internal {
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/02bd8488/3rdparty/libprocess/src/tests/process_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp
index 8a1ca9f..be288c3 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -1267,3 +1267,149 @@ TEST(Process, provide)
 
   ASSERT_SOME(os::rmdir(path));
 }
+
+
+#if __cplusplus >= 201103L
+int baz(string s) { return 42; }
+
+Future<int> bam(string s) { return 42; }
+
+
+TEST(Process, defers)
+{
+  {
+    std::function<Future<int>(string)> f =
+      defer(std::bind(baz, std::placeholders::_1));
+
+    Deferred<Future<int>(string)> d =
+      defer(std::bind(baz, std::placeholders::_1));
+
+    Future<int> future = Future<string>().then(
+        defer(std::bind(baz, std::placeholders::_1)));
+
+    Future<int> future3 = Future<string>().then(
+        std::bind(baz, std::placeholders::_1));
+
+    Future<string>().then(std::function<int(string)>());
+    Future<string>().then(std::function<int(void)>());
+
+    Future<int> future11 = Future<string>().then(
+        defer(std::bind(bam, std::placeholders::_1)));
+
+    Future<int> future12 = Future<string>().then(
+        std::bind(bam, std::placeholders::_1));
+
+    std::function<Future<int>(string)> f2 =
+      defer([] (string s) { return baz(s); });
+
+    Deferred<Future<int>(string)> d2 =
+      defer([] (string s) { return baz(s); });
+
+    Future<int> future2 = Future<string>().then(
+        defer([] (string s) { return baz(s); }));
+
+    Future<int> future4 = Future<string>().then(
+        [] (string s) { return baz(s); });
+
+    Future<int> future5 = Future<string>().then(
+        defer([] (string s) -> Future<int> { return baz(s); }));
+
+    Future<int> future6 = Future<string>().then(
+        defer([] (string s) { return Future<int>(baz(s)); }));
+
+    Future<int> future7 = Future<string>().then(
+        defer([] (string s) { return bam(s); }));
+
+    Future<int> future8 = Future<string>().then(
+        [] (string s) { return Future<int>(baz(s)); });
+
+    Future<int> future9 = Future<string>().then(
+        [] (string s) -> Future<int> { return baz(s); });
+
+    Future<int> future10 = Future<string>().then(
+        [] (string s) { return bam(s); });
+  }
+
+//   {
+//     // CAN NOT DO IN CLANG!
+//     std::function<void(string)> f =
+//       defer(std::bind(baz, std::placeholders::_1));
+
+//     std::function<int(string)> blah;
+//     std::function<void(string)> blam = blah;
+
+//     std::function<void(string)> f2 =
+//       defer([] (string s) { return baz(s); });
+//   }
+
+//   {
+//     // CAN NOT DO WITH GCC OR CLANG!
+//     std::function<int(int)> f =
+//       defer(std::bind(baz, std::placeholders::_1));
+//   }
+
+  {
+    std::function<Future<int>(void)> f =
+      defer(std::bind(baz, "42"));
+
+    std::function<Future<int>(void)> f2 =
+      defer([] () { return baz("42"); });
+  }
+
+  {
+    std::function<Future<int>(int)> f =
+      defer(std::bind(baz, "42"));
+
+    std::function<Future<int>(int)> f2 =
+      defer([] (int i) { return baz("42"); });
+  }
+
+  // Don't care about value passed from Future::then.
+  {
+    Future<int> future = Future<string>().then(
+        defer(std::bind(baz, "42")));
+
+    Future<int> future3 = Future<string>().then(
+        std::bind(baz, "42"));
+
+    Future<int> future11 = Future<string>().then(
+        defer(std::bind(bam, "42")));
+
+    Future<int> future12 = Future<string>().then(
+        std::bind(bam, "42"));
+
+    Future<int> future2 = Future<string>().then(
+        defer([] () { return baz("42"); }));
+
+    Future<int> future4 = Future<string>().then(
+        [] () { return baz("42"); });
+
+    Future<int> future5 = Future<string>().then(
+        defer([] () -> Future<int> { return baz("42"); }));
+
+    Future<int> future6 = Future<string>().then(
+        defer([] () { return Future<int>(baz("42")); }));
+
+    Future<int> future7 = Future<string>().then(
+        defer([] () { return bam("42"); }));
+
+    Future<int> future8 = Future<string>().then(
+        [] () { return Future<int>(baz("42")); });
+
+    Future<int> future9 = Future<string>().then(
+        [] () -> Future<int> { return baz("42"); });
+
+    Future<int> future10 = Future<string>().then(
+        [] () { return bam("42"); });
+  }
+
+  struct Functor
+  {
+    int operator () (string) const { return 42; }
+    int operator () () const { return 42; }
+  } functor;
+
+  Future<int> future13 = Future<string>().then(
+      defer(functor));
+}
+#endif // __cplusplus >= 201103L


[09/15] git commit: Fixed warning given by clang.

Posted by be...@apache.org.
Fixed warning given by clang.

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


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

Branch: refs/heads/master
Commit: 95eda5ad47c6c6db7d3d4d903f4337a8c926b4a6
Parents: a151dd9
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:52:07 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:00:40 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/95eda5ad/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
index ef36f1b..97ebe81 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
@@ -8,6 +8,7 @@
 #include <string>
 
 #include "error.hpp"
+#include "stringify.hpp"
 #include "try.hpp"
 
 // Compression utilities.
@@ -38,7 +39,7 @@ inline Try<std::string> compress(
   // Verify the level is within range.
   if (!(level == Z_DEFAULT_COMPRESSION ||
       (level >= Z_NO_COMPRESSION && level <= Z_BEST_COMPRESSION))) {
-    return Error("Invalid compression level: " + level);
+    return Error("Invalid compression level: " + stringify(level));
   }
 
   z_stream_s stream;


[05/15] Replaced 'std::tr1' with 'lambda' and 'memory' in libprocess.

Posted by be...@apache.org.
http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp
index 4122b96..02e89bd 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -11,14 +11,13 @@
 
 #include <glog/logging.h>
 
-#include <tr1/functional>
-#include <tr1/memory> // TODO(benh): Replace shared_ptr with unique_ptr.
-
 #include <process/latch.hpp>
 #include <process/pid.hpp>
 
 #include <stout/duration.hpp>
 #include <stout/error.hpp>
+#include <stout/lambda.hpp>
+#include <stout/memory.hpp> // TODO(benh): Replace shared_ptr with unique_ptr.
 #include <stout/none.hpp>
 #include <stout/option.hpp>
 #include <stout/preprocessor.hpp>
@@ -27,6 +26,10 @@ namespace process {
 
 // Forward declaration (instead of include to break circular dependency).
 template <typename _F> struct _Defer;
+template <typename F> struct Deferred;
+#if  __cplusplus >= 201103L
+template <typename G> struct _Deferred;
+#endif // __cplusplus >= 201103L
 
 namespace internal {
 
@@ -97,10 +100,10 @@ public:
 
   // Type of the callback functions that can get invoked when the
   // future gets set, fails, or is discarded.
-  typedef std::tr1::function<void(const T&)> ReadyCallback;
-  typedef std::tr1::function<void(const std::string&)> FailedCallback;
-  typedef std::tr1::function<void(void)> DiscardedCallback;
-  typedef std::tr1::function<void(const Future<T>&)> AnyCallback;
+  typedef lambda::function<void(const T&)> ReadyCallback;
+  typedef lambda::function<void(const std::string&)> FailedCallback;
+  typedef lambda::function<void(void)> DiscardedCallback;
+  typedef lambda::function<void(const Future<T>&)> AnyCallback;
 
   // Installs callbacks for the specified events and returns a const
   // reference to 'this' in order to easily support chaining.
@@ -109,14 +112,80 @@ public:
   const Future<T>& onDiscarded(const DiscardedCallback& callback) const;
   const Future<T>& onAny(const AnyCallback& callback) const;
 
+#if __cplusplus >= 201103L
+  template <typename F>
+  const Future<T>& onReady(const _Deferred<F>& deferred) const
+  {
+    return onReady(std::function<void(const T&)>(deferred));
+  }
+
+  template <typename F>
+  const Future<T>& onFailed(const _Deferred<F>& deferred) const
+  {
+    return onFailed(std::function<void(const std::string&)>(deferred));
+  }
+
+  template <typename F>
+  const Future<T>& onAny(const _Deferred<F>& deferred) const
+  {
+    return onAny(std::function<void(const Future<T>&)>(deferred));
+  }
+
+  const Future<T>& onReady(const Deferred<void(void)>& deferred) const
+  {
+    return onReady(std::function<void(const T&)>(lambda::bind(deferred)));
+  }
+
+  const Future<T>& onFailed(const Deferred<void(void)>& deferred) const
+  {
+    return onFailed(std::function<void(const std::string&)>(lambda::bind(deferred)));
+  }
+
+  const Future<T>& onAny(const Deferred<void(void)>& deferred) const
+  {
+    return onAny(std::function<void(const Future<T>&)>(lambda::bind(deferred)));
+  }
+#endif // __cplusplus >= 201103L
+
   // Installs callbacks that get executed when this future is ready
   // and associates the result of the callback with the future that is
   // returned to the caller (which may be of a different type).
   template <typename X>
-  Future<X> then(const std::tr1::function<Future<X>(const T&)>& f) const;
+  Future<X> then(const lambda::function<Future<X>(const T&)>& f) const;
 
   template <typename X>
-  Future<X> then(const std::tr1::function<X(const T&)>& f) const;
+  Future<X> then(const lambda::function<X(const T&)>& f) const;
+
+  template <typename X>
+  Future<X> then(const lambda::function<Future<X>(void)>& f) const
+  {
+    return then(lambda::function<Future<X>(const T&)>(lambda::bind(f)));
+  }
+
+  template <typename X>
+  Future<X> then(const lambda::function<X(void)>& f) const
+  {
+    return then(lambda::function<X(const T&)>(lambda::bind(f)));
+  }
+
+#if __cplusplus >= 201103L
+  template <typename F>
+  typename internal::wrap<typename std::result_of<F(const T&)>::type>::Type
+  then(F f) const
+  {
+    typedef typename std::result_of<F(const T&)>::type R;
+    return then(std::function<R(const T&)>(f));
+  }
+
+  template <typename F>
+  typename internal::wrap<typename std::result_of<F(const T&)>::type>::Type
+  then(const _Deferred<F>& deferred) const
+  {
+    typedef typename std::result_of<F(const T&)>::type R;
+    return then(std::function<R(const T&)>(deferred));
+  }
+
+#else // __cplusplus >= 201103L
 
   // Helpers for the compiler to be able to forward std::tr1::bind results.
   template <typename X>
@@ -211,13 +280,7 @@ public:
 
   REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
 #undef TEMPLATE
-
-  // C++11 implementation (covers all functors).
-#if __cplusplus >= 201103L
-  template <typename F>
-  auto then(F f) const
-    -> typename internal::wrap<decltype(f(T()))>::Type;
-#endif
+#endif // __cplusplus >= 201103L
 
 private:
   friend class Promise<T>;
@@ -255,7 +318,7 @@ private:
   // failed, or discarded, in which case it returns false.
   bool fail(const std::string& _message);
 
-  std::tr1::shared_ptr<Data> data;
+  memory::shared_ptr<Data> data;
 };
 
 
@@ -272,7 +335,7 @@ public:
   Option<Future<T> > get();
 
 private:
-  std::tr1::weak_ptr<typename Future<T>::Data> data;
+  memory::weak_ptr<typename Future<T>::Data> data;
 };
 
 
@@ -409,16 +472,16 @@ bool Promise<T>::associate(const Future<T>& future)
   // In other words, calling 'set' or 'fail' on this promise will not
   // affect the result of the future that we associated. To avoid
   // cyclic dependencies, we keep a weak future in the callback.
-  f.onDiscarded(std::tr1::bind(&internal::discard<T>, WeakFuture<T>(future)));
+  f.onDiscarded(lambda::bind(&internal::discard<T>, WeakFuture<T>(future)));
 
   if (!f.isPending()) {
     return false;
   }
 
   future
-    .onReady(std::tr1::bind(&Future<T>::set, f, std::tr1::placeholders::_1))
-    .onFailed(std::tr1::bind(&Future<T>::fail, f, std::tr1::placeholders::_1))
-    .onDiscarded(std::tr1::bind(&Future<T>::discard, f));
+    .onReady(lambda::bind(&Future<T>::set, f, lambda::_1))
+    .onFailed(lambda::bind(&Future<T>::fail, f, lambda::_1))
+    .onDiscarded(lambda::bind(&Future<T>::discard, f));
 
   return true;
 }
@@ -488,7 +551,7 @@ inline void release(int* lock)
 template <typename T>
 void select(
     const Future<T>& future,
-    std::tr1::shared_ptr<Promise<Future<T > > > promise)
+    memory::shared_ptr<Promise<Future<T > > > promise)
 {
   // We never fail the future associated with our promise.
   assert(!promise->future().isFailed());
@@ -510,19 +573,17 @@ void select(
 template <typename T>
 Future<Future<T> > select(const std::set<Future<T> >& futures)
 {
-  std::tr1::shared_ptr<Promise<Future<T> > > promise(
+  memory::shared_ptr<Promise<Future<T> > > promise(
       new Promise<Future<T> >());
 
   Future<Future<T> > future = promise->future();
 
-  std::tr1::function<void(const Future<T>&)> select =
-    std::tr1::bind(&internal::select<T>,
-                   std::tr1::placeholders::_1,
-                   promise);
+  lambda::function<void(const Future<T>&)> select =
+    lambda::bind(&internal::select<T>, lambda::_1, promise);
 
   typename std::set<Future<T> >::iterator iterator;
   for (iterator = futures.begin(); iterator != futures.end(); ++iterator) {
-    (*iterator).onAny(std::tr1::bind(select, std::tr1::placeholders::_1));
+    (*iterator).onAny(lambda::bind(select, lambda::_1));
   }
 
   return future;
@@ -878,8 +939,8 @@ const Future<T>& Future<T>::onAny(const AnyCallback& callback) const
 namespace internal {
 
 template <typename T, typename X>
-void thenf(const std::tr1::shared_ptr<Promise<X> >& promise,
-           const std::tr1::function<Future<X>(const T&)>& f,
+void thenf(const memory::shared_ptr<Promise<X> >& promise,
+           const lambda::function<Future<X>(const T&)>& f,
            const Future<T>& future)
 {
   if (future.isReady()) {
@@ -893,8 +954,8 @@ void thenf(const std::tr1::shared_ptr<Promise<X> >& promise,
 
 
 template <typename T, typename X>
-void then(const std::tr1::shared_ptr<Promise<X> >& promise,
-          const std::tr1::function<X(const T&)>& f,
+void then(const memory::shared_ptr<Promise<X> >& promise,
+          const lambda::function<X(const T&)>& f,
           const Future<T>& future)
 {
   if (future.isReady()) {
@@ -911,22 +972,19 @@ void then(const std::tr1::shared_ptr<Promise<X> >& promise,
 
 template <typename T>
 template <typename X>
-Future<X> Future<T>::then(const std::tr1::function<Future<X>(const T&)>& f) const
+Future<X> Future<T>::then(const lambda::function<Future<X>(const T&)>& f) const
 {
-  std::tr1::shared_ptr<Promise<X> > promise(new Promise<X>());
+  memory::shared_ptr<Promise<X> > promise(new Promise<X>());
 
-  std::tr1::function<void(const Future<T>&)> thenf =
-    std::tr1::bind(&internal::thenf<T, X>,
-                   promise,
-                   f,
-                   std::tr1::placeholders::_1);
+  lambda::function<void(const Future<T>&)> thenf =
+    lambda::bind(&internal::thenf<T, X>, promise, f, lambda::_1);
 
   onAny(thenf);
 
   // Propagate discarding up the chain. To avoid cyclic dependencies,
   // we keep a weak future in the callback.
   promise->future().onDiscarded(
-      std::tr1::bind(&internal::discard<T>, WeakFuture<T>(*this)));
+      lambda::bind(&internal::discard<T>, WeakFuture<T>(*this)));
 
   return promise->future();
 }
@@ -934,58 +992,22 @@ Future<X> Future<T>::then(const std::tr1::function<Future<X>(const T&)>& f) cons
 
 template <typename T>
 template <typename X>
-Future<X> Future<T>::then(const std::tr1::function<X(const T&)>& f) const
+Future<X> Future<T>::then(const lambda::function<X(const T&)>& f) const
 {
-  std::tr1::shared_ptr<Promise<X> > promise(new Promise<X>());
+  memory::shared_ptr<Promise<X> > promise(new Promise<X>());
 
-  std::tr1::function<void(const Future<T>&)> then =
-    std::tr1::bind(&internal::then<T, X>,
-                   promise,
-                   f,
-                   std::tr1::placeholders::_1);
+  lambda::function<void(const Future<T>&)> then =
+    lambda::bind(&internal::then<T, X>, promise, f, lambda::_1);
 
   onAny(then);
 
   // Propagate discarding up the chain. To avoid cyclic dependencies,
   // we keep a weak future in the callback.
   promise->future().onDiscarded(
-      std::tr1::bind(&internal::discard<T>, WeakFuture<T>(*this)));
-
-  return promise->future();
-}
-
-
-#if __cplusplus >= 201103L
-template <typename T>
-template <typename F>
-auto Future<T>::then(F f) const
-  -> typename internal::wrap<decltype(f(T()))>::Type
-{
-  typedef typename internal::unwrap<decltype(f(T()))>::Type X;
-
-  std::tr1::shared_ptr<Promise<X>> promise(new Promise<X>());
-
-  onAny([=] (const Future<T>& future) {
-    if (future.isReady()) {
-      promise->set(f(future.get()));
-    } else if (future.isFailed()) {
-      promise->fail(future.failure());
-    } else if (future.isDiscarded()) {
-      promise->future().discard();
-    }
-  });
-
-  // Propagate discarding up the chain. To avoid cyclic dependencies,
-  // we keep a weak future in the callback.
-  WeakFuture<T> reference(*this);
-
-  promise->future().onDiscarded([=] () {
-    internal::discard(reference);
-  });
+      lambda::bind(&internal::discard<T>, WeakFuture<T>(*this)));
 
   return promise->future();
 }
-#endif
 
 
 template <typename T>

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/gmock.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/gmock.hpp b/3rdparty/libprocess/include/process/gmock.hpp
index a8cab4c..daba7e3 100644
--- a/3rdparty/libprocess/include/process/gmock.hpp
+++ b/3rdparty/libprocess/include/process/gmock.hpp
@@ -5,8 +5,6 @@
 
 #include <gmock/gmock.h>
 
-#include <tr1/tuple>
-
 #include <process/dispatch.hpp>
 #include <process/event.hpp>
 #include <process/filter.hpp>
@@ -15,6 +13,11 @@
 #include <stout/exit.hpp>
 #include <stout/nothing.hpp>
 
+// NOTE: The gmock library relies on std::tr1::tuple. The gmock
+// library provides multiple possible 'tuple' implementations but it
+// still uses std::tr1::tuple as the "type" name, hence our use of it
+// in this file.
+
 
 // THIS IS DEPRECATED AND BROKEN! REPLACE ALL USES!
 #define EXPECT_MESSAGE(name, from, to)                                  \

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/process.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/process.hpp b/3rdparty/libprocess/include/process/process.hpp
index d9dc571..37283ea 100644
--- a/3rdparty/libprocess/include/process/process.hpp
+++ b/3rdparty/libprocess/include/process/process.hpp
@@ -7,8 +7,6 @@
 #include <map>
 #include <queue>
 
-#include <tr1/functional>
-
 #include <process/clock.hpp>
 #include <process/event.hpp>
 #include <process/filter.hpp>
@@ -18,6 +16,7 @@
 #include <process/pid.hpp>
 
 #include <stout/duration.hpp>
+#include <stout/lambda.hpp>
 #include <stout/option.hpp>
 #include <stout/thread.hpp>
 
@@ -85,7 +84,7 @@ protected:
   // always takes precedence over delegating). A message handler is
   // any function which takes two arguments, the "from" pid and the
   // message body.
-  typedef std::tr1::function<void(const UPID&, const std::string&)>
+  typedef lambda::function<void(const UPID&, const std::string&)>
   MessageHandler;
 
   // Setup a handler for a message.
@@ -105,10 +104,7 @@ protected:
     // multiple inheritance if it sees so fit (e.g., to implement
     // multiple callback interfaces).
     MessageHandler handler =
-      std::tr1::bind(method,
-                     dynamic_cast<T*>(this),
-                     std::tr1::placeholders::_1,
-                     std::tr1::placeholders::_2);
+      lambda::bind(method, dynamic_cast<T*>(this), lambda::_1, lambda::_2);
     install(name, handler);
   }
 
@@ -121,7 +117,7 @@ protected:
   // The default visit implementation for HTTP events invokes
   // installed HTTP handlers. A HTTP handler is any function which
   // takes an http::Request object and returns an http::Response.
-  typedef std::tr1::function<Future<http::Response>(const http::Request&)>
+  typedef lambda::function<Future<http::Response>(const http::Request&)>
   HttpRequestHandler;
 
   // Setup a handler for an HTTP request.
@@ -140,8 +136,7 @@ protected:
     // multiple inheritance if it sees so fit (e.g., to implement
     // multiple callback interfaces).
     HttpRequestHandler handler =
-      std::tr1::bind(method, dynamic_cast<T*>(this),
-                     std::tr1::placeholders::_1);
+      lambda::bind(method, dynamic_cast<T*>(this), lambda::_1);
     return route(name, help, handler);
   }
 
@@ -269,6 +264,11 @@ uint16_t port();
  */
 UPID spawn(ProcessBase* process, bool manage = false);
 
+inline UPID spawn(ProcessBase& process, bool manage = false)
+{
+  return spawn(&process, manage);
+}
+
 template <typename T>
 PID<T> spawn(T* t, bool manage = false)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/protobuf.hpp b/3rdparty/libprocess/include/process/protobuf.hpp
index 5a6fc83..7500601 100644
--- a/3rdparty/libprocess/include/process/protobuf.hpp
+++ b/3rdparty/libprocess/include/process/protobuf.hpp
@@ -9,12 +9,10 @@
 #include <set>
 #include <vector>
 
-#include <tr1/functional>
-#include <tr1/unordered_map>
-
 #include <process/dispatch.hpp>
 #include <process/process.hpp>
 
+#include <stout/hashmap.hpp>
 #include <stout/lambda.hpp>
 
 
@@ -667,7 +665,7 @@ private:
 
   typedef lambda::function<
       void(const process::UPID&, const std::string&)> handler;
-  std::tr1::unordered_map<std::string, handler> protobufHandlers;
+  hashmap<std::string, handler> protobufHandlers;
 
   // Sender of "current" message, inaccessible by subclasses.
   // This is only used for reply().

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/run.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/run.hpp b/3rdparty/libprocess/include/process/run.hpp
index a245b70..924d31a 100644
--- a/3rdparty/libprocess/include/process/run.hpp
+++ b/3rdparty/libprocess/include/process/run.hpp
@@ -1,10 +1,10 @@
 #ifndef __PROCESS_RUN_HPP__
 #define __PROCESS_RUN_HPP__
 
-#include <tr1/memory> // TODO(benh): Replace shared_ptr with unique_ptr.
-
 #include <process/process.hpp>
 
+#include <stout/lambda.hpp>
+#include <stout/memory.hpp> // TODO(benh): Replace shared_ptr with unique_ptr.
 #include <stout/preprocessor.hpp>
 
 namespace process {
@@ -15,8 +15,8 @@ template <typename R>
 class ThunkProcess : public Process<ThunkProcess<R> >
 {
 public:
-  ThunkProcess(std::tr1::shared_ptr<std::tr1::function<R(void)> > _thunk,
-               std::tr1::shared_ptr<Promise<R> > _promise)
+  ThunkProcess(memory::shared_ptr<lambda::function<R(void)> > _thunk,
+               memory::shared_ptr<Promise<R> > _promise)
     : thunk(_thunk),
       promise(_promise) {}
 
@@ -29,8 +29,8 @@ protected:
   }
 
 private:
-  std::tr1::shared_ptr<std::tr1::function<R(void)> > thunk;
-  std::tr1::shared_ptr<Promise<R> > promise;
+  memory::shared_ptr<lambda::function<R(void)> > thunk;
+  memory::shared_ptr<Promise<R> > promise;
 };
 
 } // namespace internal {
@@ -39,11 +39,11 @@ private:
 template <typename R>
 Future<R> run(R (*method)(void))
 {
-  std::tr1::shared_ptr<std::tr1::function<R(void)> > thunk(
-      new std::tr1::function<R(void)>(
-          std::tr1::bind(method)));
+  memory::shared_ptr<lambda::function<R(void)> > thunk(
+      new lambda::function<R(void)>(
+          lambda::bind(method)));
 
-  std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());
+  memory::shared_ptr<Promise<R> > promise(new Promise<R>());
   Future<R> future = promise->future();
 
   terminate(spawn(new internal::ThunkProcess<R>(thunk, promise), true));
@@ -60,11 +60,11 @@ Future<R> run(R (*method)(void))
       R (*method)(ENUM_PARAMS(N, P)),                                   \
       ENUM_BINARY_PARAMS(N, A, a))                                      \
   {                                                                     \
-    std::tr1::shared_ptr<std::tr1::function<R(void)> > thunk(           \
-        new std::tr1::function<R(void)>(                                \
-            std::tr1::bind(method, ENUM_PARAMS(N, a))));                \
+    memory::shared_ptr<lambda::function<R(void)> > thunk(               \
+        new lambda::function<R(void)>(                                  \
+            lambda::bind(method, ENUM_PARAMS(N, a))));                  \
                                                                         \
-    std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());        \
+    memory::shared_ptr<Promise<R> > promise(new Promise<R>());          \
     Future<R> future = promise->future();                               \
                                                                         \
     terminate(spawn(new internal::ThunkProcess<R>(thunk, promise), true)); \

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/timer.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/timer.hpp b/3rdparty/libprocess/include/process/timer.hpp
index 333a806..3400eb0 100644
--- a/3rdparty/libprocess/include/process/timer.hpp
+++ b/3rdparty/libprocess/include/process/timer.hpp
@@ -3,11 +3,10 @@
 
 #include <stdlib.h> // For abort.
 
-#include <tr1/functional>
-
 #include <process/timeout.hpp>
 
 #include <stout/duration.hpp>
+#include <stout/lambda.hpp>
 
 namespace process {
 
@@ -20,7 +19,7 @@ public:
 
   static Timer create(
       const Duration& duration,
-      const std::tr1::function<void(void)>& thunk);
+      const lambda::function<void(void)>& thunk);
 
   static bool cancel(const Timer& timer);
 
@@ -53,7 +52,7 @@ private:
   Timer(long _id,
         const Timeout& _t,
         const process::UPID& _pid,
-        const std::tr1::function<void(void)>& _thunk)
+        const lambda::function<void(void)>& _thunk)
     : id(_id), t(_t), pid(_pid), thunk(_thunk)
   {}
 
@@ -68,7 +67,7 @@ private:
   // valid and get a refernce to it.)
   process::UPID pid;
 
-  std::tr1::function<void(void)> thunk;
+  lambda::function<void(void)> thunk;
 };
 
 } // namespace process {

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 2d193b1..67f7f9b 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -40,9 +40,6 @@
 #include <stdexcept>
 #include <vector>
 
-#include <tr1/functional>
-#include <tr1/memory> // TODO(benh): Replace all shared_ptr with unique_ptr.
-
 #include <boost/shared_array.hpp>
 
 #include <process/clock.hpp>
@@ -68,6 +65,7 @@
 #include <stout/duration.hpp>
 #include <stout/foreach.hpp>
 #include <stout/lambda.hpp>
+#include <stout/memory.hpp> // TODO(benh): Replace shared_ptr with unique_ptr.
 #include <stout/net.hpp>
 #include <stout/os.hpp>
 #include <stout/strings.hpp>
@@ -3177,8 +3175,7 @@ void ProcessBase::visit(const HttpEvent& event)
   if (handlers.http.count(name) > 0) {
     // Create the promise to link with whatever gets returned, as well
     // as a future to wait for the response.
-    std::tr1::shared_ptr<Promise<Response> > promise(
-        new Promise<Response>());
+    memory::shared_ptr<Promise<Response> > promise(new Promise<Response>());
 
     Future<Response>* future = new Future<Response>(promise->future());
 
@@ -3420,7 +3417,7 @@ namespace internal {
 void read(int fd,
           void* data,
           size_t size,
-          const std::tr1::shared_ptr<Promise<size_t> >& promise,
+          const memory::shared_ptr<Promise<size_t> >& promise,
           const Future<short>& future)
 {
   // Ignore this function if the read operation has been cancelled.
@@ -3487,7 +3484,7 @@ Future<size_t> read(int fd, void* data, size_t size)
 {
   process::initialize();
 
-  std::tr1::shared_ptr<Promise<size_t> > promise(new Promise<size_t>());
+  memory::shared_ptr<Promise<size_t> > promise(new Promise<size_t>());
 
   // Check the file descriptor.
   Try<bool> nonblock = os::isNonblock(fd);
@@ -3522,23 +3519,23 @@ namespace internal {
 
 #if __cplusplus >= 201103L
 Future<string> _read(int fd,
-                     const std::tr1::shared_ptr<string>& buffer,
+                     const memory::shared_ptr<string>& buffer,
                      const boost::shared_array<char>& data,
                      size_t length)
 {
   return io::read(fd, data.get(), length)
-    .then([=] (size_t size) {
+    .then([=] (size_t size) -> Future<string> {
       if (size == 0) { // EOF.
         return string(*buffer);
       }
-      buffer->append(data, size);
+      buffer->append(data.get(), size);
       return _read(fd, buffer, data, length);
     });
 }
 #else
 // Forward declataion.
 Future<string> _read(int fd,
-                     const std::tr1::shared_ptr<string>& buffer,
+                     const memory::shared_ptr<string>& buffer,
                      const boost::shared_array<char>& data,
                      size_t length);
 
@@ -3547,7 +3544,7 @@ Future<string> __read(
     const size_t& size,
     // TODO(benh): Remove 'const &' after fixing libprocess.
     int fd,
-    const std::tr1::shared_ptr<string>& buffer,
+    const memory::shared_ptr<string>& buffer,
     const boost::shared_array<char>& data,
     size_t length)
 {
@@ -3562,14 +3559,14 @@ Future<string> __read(
 
 
 Future<string> _read(int fd,
-                     const std::tr1::shared_ptr<string>& buffer,
+                     const memory::shared_ptr<string>& buffer,
                      const boost::shared_array<char>& data,
                      size_t length)
 {
   return io::read(fd, data.get(), length)
     .then(lambda::bind(&__read, lambda::_1, fd, buffer, data, length));
 }
-#endif
+#endif // __cplusplus >= 201103L
 
 } // namespace internal
 
@@ -3580,7 +3577,7 @@ Future<string> read(int fd)
 
   // TODO(benh): Wrap up this data as a struct, use 'Owner'.
   // TODO(bmahler): For efficiency, use a rope for the buffer.
-  std::tr1::shared_ptr<string> buffer(new string());
+  memory::shared_ptr<string> buffer(new string());
   boost::shared_array<char> data(new char[BUFFERED_READ_SIZE]);
 
   return internal::_read(fd, buffer, data, BUFFERED_READ_SIZE);
@@ -3695,7 +3692,7 @@ namespace internal {
 
 void dispatch(
     const UPID& pid,
-    const std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> >& f,
+    const memory::shared_ptr<lambda::function<void(ProcessBase*)> >& f,
     const string& method)
 {
   process::initialize();

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/src/tests/process_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp
index b0fb5c2..8a1ca9f 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -27,6 +27,7 @@
 
 #include <stout/duration.hpp>
 #include <stout/gtest.hpp>
+#include <stout/lambda.hpp>
 #include <stout/nothing.hpp>
 #include <stout/os.hpp>
 #include <stout/stringify.hpp>
@@ -107,7 +108,7 @@ TEST(Process, onAny)
 {
   bool b = false;
   Future<bool>(true)
-    .onAny(std::tr1::bind(&onAny, std::tr1::placeholders::_1, &b));
+    .onAny(lambda::bind(&onAny, lambda::_1, &b));
   EXPECT_TRUE(b);
 }
 
@@ -137,13 +138,13 @@ TEST(Process, then)
   promise.set(&i);
 
   Future<string> future = promise.future()
-    .then(std::tr1::bind(&itoa1, std::tr1::placeholders::_1));
+    .then(lambda::bind(&itoa1, lambda::_1));
 
   ASSERT_TRUE(future.isReady());
   EXPECT_EQ("42", future.get());
 
   future = promise.future()
-    .then(std::tr1::bind(&itoa2, std::tr1::placeholders::_1));
+    .then(lambda::bind(&itoa2, lambda::_1));
 
   ASSERT_TRUE(future.isReady());
   EXPECT_EQ("42", future.get());
@@ -185,8 +186,8 @@ TEST(Process, chain)
   Promise<int*> promise;
 
   Future<string> s = readyFuture()
-    .then(std::tr1::bind(&second, std::tr1::placeholders::_1))
-    .then(std::tr1::bind(&third, std::tr1::placeholders::_1));
+    .then(lambda::bind(&second, lambda::_1))
+    .then(lambda::bind(&third, lambda::_1));
 
   s.await();
 
@@ -194,8 +195,8 @@ TEST(Process, chain)
   EXPECT_EQ("true", s.get());
 
   s = failedFuture()
-    .then(std::tr1::bind(&second, std::tr1::placeholders::_1))
-    .then(std::tr1::bind(&third, std::tr1::placeholders::_1));
+    .then(lambda::bind(&second, lambda::_1))
+    .then(lambda::bind(&third, lambda::_1));
 
   s.await();
 
@@ -204,8 +205,8 @@ TEST(Process, chain)
   Future<bool> future;
 
   s = pendingFuture(&future)
-    .then(std::tr1::bind(&second, std::tr1::placeholders::_1))
-    .then(std::tr1::bind(&third, std::tr1::placeholders::_1));
+    .then(lambda::bind(&second, lambda::_1))
+    .then(lambda::bind(&third, lambda::_1));
 
   ASSERT_TRUE(s.isPending());
   ASSERT_TRUE(future.isPending());
@@ -349,14 +350,14 @@ TEST(Process, defer1)
 
   {
     Deferred<Future<bool>(bool)> func4 =
-      defer(pid, &DispatchProcess::func4, std::tr1::placeholders::_1, 42);
+      defer(pid, &DispatchProcess::func4, lambda::_1, 42);
     future = func4(false);
     EXPECT_FALSE(future.get());
   }
 
   {
     Deferred<Future<bool>(int)> func4 =
-      defer(pid, &DispatchProcess::func4, true, std::tr1::placeholders::_1);
+      defer(pid, &DispatchProcess::func4, true, lambda::_1);
     future = func4(42);
     EXPECT_TRUE(future.get());
   }
@@ -373,7 +374,7 @@ class DeferProcess : public Process<DeferProcess>
 public:
   Future<string> func1(const Future<int>& f)
   {
-    return f.then(defer(self(), &Self::_func1, std::tr1::placeholders::_1));
+    return f.then(defer(self(), &Self::_func1, lambda::_1));
   }
 
   Future<string> func2(const Future<int>& f)
@@ -436,18 +437,26 @@ TEST(Process, defer3)
   volatile bool bool2 = false;
 
   Deferred<void(bool)> set1 =
+#if __cplusplus >= 201103L
+    defer([&bool1] (bool b) { bool1 = b; });
+#else // __cplusplus >= 201103L
     defer(std::tr1::function<void(bool)>(
               std::tr1::bind(&set<volatile bool>,
                              &bool1,
                              std::tr1::placeholders::_1)));
+#endif // __cplusplus >= 201103L
 
   set1(true);
 
   Deferred<void(bool)> set2 =
+#if __cplusplus >= 201103L
+    defer([&bool2] (bool b) { bool2 = b; });
+#else // __cplusplus >= 201103L
     defer(std::tr1::function<void(bool)>(
               std::tr1::bind(&set<volatile bool>,
                              &bool2,
                              std::tr1::placeholders::_1)));
+#endif // __cplusplus >= 201103L
 
   set2(true);
 
@@ -1056,16 +1065,17 @@ TEST(Process, executor)
   Executor executor;
 
   Deferred<void(int)> event1 =
-    executor.defer(std::tr1::bind(&EventReceiver::event1,
-                                  &receiver,
-                                  std::tr1::placeholders::_1));
-
+    executor.defer(lambda::function<void(int)>(
+                       lambda::bind(&EventReceiver::event1,
+                                    &receiver,
+                                    lambda::_1)));
   event1(42);
 
   Deferred<void(const string&)> event2 =
-    executor.defer(std::tr1::bind(&EventReceiver::event2,
-                                  &receiver,
-                                  std::tr1::placeholders::_1));
+    executor.defer(lambda::function<void(const string&)>(
+                       lambda::bind(&EventReceiver::event2,
+                                    &receiver,
+                                    lambda::_1)));
 
   event2("event2");
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/src/timer.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/timer.cpp b/3rdparty/libprocess/src/timer.cpp
index 63c5ac1..aa1ee1b 100644
--- a/3rdparty/libprocess/src/timer.cpp
+++ b/3rdparty/libprocess/src/timer.cpp
@@ -1,6 +1,7 @@
+#include <process/timeout.hpp>
 #include <process/timer.hpp>
 
-#include "timeout.hpp"
+#include <stout/lambda.hpp>
 
 namespace process {
 
@@ -9,7 +10,7 @@ class TimerProcess : public Process<TimerProcess>
 public:
   TimerProcess(double _secs,
                const UPID& _pid,
-               std::tr1::function<void(ProcessBase*)>* _dispatcher)
+               lambda::function<void(ProcessBase*)>* _dispatcher)
     : secs(_secs), pid(_pid), dispatcher(_dispatcher) {}
 
 protected:
@@ -25,7 +26,7 @@ protected:
 private:
   const double secs;
   const UPID pid;
-  std::tr1::function<void(ProcessBase*)>* dispatcher;
+  lambda::function<void(ProcessBase*)>* dispatcher;
 };
 
 
@@ -34,7 +35,7 @@ static void dispatch()
 
 Timer::Timer(double secs,
              const UPID& pid,
-             std::tr1::function<void(ProcessBase*)>* dispatcher)
+             lambda::function<void(ProcessBase*)>* dispatcher)
 {
   timer = spawn(new TimerProcess(secs, pid, dispatcher), true);
 }


[03/15] git commit: Upgraded libprocess to protobuf 2.5.0.

Posted by be...@apache.org.
Upgraded libprocess to protobuf 2.5.0.

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


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

Branch: refs/heads/master
Commit: bdc372d62f01a531fa16be4df1f2c2707e3a3e66
Parents: 72a1e19
Author: Benjamin Hindman <be...@gmail.com>
Authored: Mon Dec 30 11:13:30 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Jan 13 23:38:54 2014 -0800

----------------------------------------------------------------------
 .../libprocess/3rdparty/protobuf-2.4.1.tar.gz    | Bin 1935301 -> 0 bytes
 .../libprocess/3rdparty/protobuf-2.5.0.tar.gz    | Bin 0 -> 2401901 bytes
 3rdparty/libprocess/3rdparty/versions.am         |   4 ++--
 3 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bdc372d6/3rdparty/libprocess/3rdparty/protobuf-2.4.1.tar.gz
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/protobuf-2.4.1.tar.gz b/3rdparty/libprocess/3rdparty/protobuf-2.4.1.tar.gz
deleted file mode 100644
index 38ec4de..0000000
Binary files a/3rdparty/libprocess/3rdparty/protobuf-2.4.1.tar.gz and /dev/null differ

http://git-wip-us.apache.org/repos/asf/mesos/blob/bdc372d6/3rdparty/libprocess/3rdparty/protobuf-2.5.0.tar.gz
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/protobuf-2.5.0.tar.gz b/3rdparty/libprocess/3rdparty/protobuf-2.5.0.tar.gz
new file mode 100644
index 0000000..e600ac5
Binary files /dev/null and b/3rdparty/libprocess/3rdparty/protobuf-2.5.0.tar.gz differ

http://git-wip-us.apache.org/repos/asf/mesos/blob/bdc372d6/3rdparty/libprocess/3rdparty/versions.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/versions.am b/3rdparty/libprocess/3rdparty/versions.am
index 7cb4f2f..7061e90 100644
--- a/3rdparty/libprocess/3rdparty/versions.am
+++ b/3rdparty/libprocess/3rdparty/versions.am
@@ -1,11 +1,11 @@
 # This automake utility file is included from 3rdparty/Makefile.am
 # and src/Makefile.am, so we can update the version numbers of
-# third_party packages in exactly one place.
+# third party packages in exactly one place.
 
 BOOST_VERSION = 1.53.0
 GLOG_VERSION = 0.3.3
 GMOCK_VERSION = 1.6.0
 GPERFTOOLS_VERSION = 2.0
 LIBEV_VERSION = 4.15
-PROTOBUF_VERSION = 2.4.1
+PROTOBUF_VERSION = 2.5.0
 RY_HTTP_PARSER_VERSION = 1c3624a


[04/15] git commit: Replaced 'std::tr1' with 'lambda' and 'memory' in stout.

Posted by be...@apache.org.
Replaced 'std::tr1' with 'lambda' and 'memory' in stout.

The 'lambda' and 'memory' namespace gives us a level-of-indirection
that makes it easier to do either C++03 or C++11 compilation.

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


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

Branch: refs/heads/master
Commit: 7f16f83dce0292ba10873f7953de30b05caa2407
Parents: 7810f9e
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 21:59:48 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Jan 13 23:48:23 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/stout/Makefile.am  |  1 +
 .../3rdparty/stout/include/stout/cache.hpp      |  5 +-
 .../3rdparty/stout/include/stout/flags/flag.hpp |  7 ++-
 .../stout/include/stout/flags/flags.hpp         | 51 ++++++++++----------
 .../stout/include/stout/flags/loader.hpp        | 11 ++---
 .../stout/include/stout/flags/parse.hpp         |  2 -
 .../stout/include/stout/flags/stringifier.hpp   |  2 -
 .../3rdparty/stout/include/stout/format.hpp     |  4 ++
 .../3rdparty/stout/include/stout/lambda.hpp     | 13 +++--
 .../3rdparty/stout/include/stout/memory.hpp     | 17 +++++++
 .../3rdparty/stout/include/stout/os/fork.hpp    |  7 ++-
 11 files changed, 70 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/Makefile.am b/3rdparty/libprocess/3rdparty/stout/Makefile.am
index 9e7a4a8..0725722 100644
--- a/3rdparty/libprocess/3rdparty/stout/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/Makefile.am
@@ -28,6 +28,7 @@ EXTRA_DIST =					\
   include/stout/json.hpp			\
   include/stout/lambda.hpp			\
   include/stout/linkedhashmap.hpp		\
+  include/stout/memory.hpp			\
   include/stout/multihashmap.hpp		\
   include/stout/multimap.hpp			\
   include/stout/net.hpp				\

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
index 653507c..443bedf 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
@@ -6,8 +6,7 @@
 #include <list>
 #include <map>
 
-#include <tr1/functional>
-#include <tr1/unordered_map>
+#include <boost/unordered_map.hpp>
 
 #include "none.hpp"
 #include "option.hpp"
@@ -30,7 +29,7 @@ class cache
 {
 public:
   typedef std::list<Key> list;
-  typedef std::tr1::unordered_map<
+  typedef boost::unordered_map<
     Key, std::pair<Value, typename list::iterator> > map;
 
   explicit cache(int _capacity) : capacity(_capacity) {}

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
index 2ba739d..14135ca 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
@@ -3,8 +3,7 @@
 
 #include <string>
 
-#include <tr1/functional>
-
+#include <stout/lambda.hpp>
 #include <stout/nothing.hpp>
 #include <stout/try.hpp>
 
@@ -18,8 +17,8 @@ struct Flag
   std::string name;
   std::string help;
   bool boolean;
-  std::tr1::function<Try<Nothing>(FlagsBase*, const std::string&)> loader;
-  std::tr1::function<Option<std::string>(const FlagsBase&)> stringify;
+  lambda::function<Try<Nothing>(FlagsBase*, const std::string&)> loader;
+  lambda::function<Option<std::string>(const FlagsBase&)> stringify;
 };
 
 } // namespace flags {

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
index 0d3c836..32d5aae 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
@@ -7,11 +7,10 @@
 #include <string>
 #include <typeinfo> // For typeid.
 
-#include <tr1/functional>
-
 #include <stout/error.hpp>
 #include <stout/exit.hpp>
 #include <stout/foreach.hpp>
+#include <stout/lambda.hpp>
 #include <stout/none.hpp>
 #include <stout/nothing.hpp>
 #include <stout/option.hpp>
@@ -149,14 +148,14 @@ void FlagsBase::add(
   flag.name = name;
   flag.help = help;
   flag.boolean = typeid(T1) == typeid(bool);
-  flag.loader = std::tr1::bind(
+  flag.loader = lambda::bind(
       &Loader<T1>::load,
       t1,
-      std::tr1::function<Try<T1>(const std::string&)>(
-          std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
+      lambda::function<Try<T1>(const std::string&)>(
+          lambda::bind(&parse<T1>, lambda::_1)),
       name,
-      std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
-  flag.stringify = std::tr1::bind(&Stringifier<T1>, t1);
+      lambda::_2); // Use _2 because ignore FlagsBase*.
+  flag.stringify = lambda::bind(&Stringifier<T1>, t1);
 
   // Update the help string to include the default value.
   flag.help += help.size() > 0 && help.find_last_of("\n\r") != help.size() - 1
@@ -179,14 +178,14 @@ void FlagsBase::add(
   flag.name = name;
   flag.help = help;
   flag.boolean = typeid(T) == typeid(bool);
-  flag.loader = std::tr1::bind(
+  flag.loader = lambda::bind(
       &OptionLoader<T>::load,
       option,
-      std::tr1::function<Try<T>(const std::string&)>(
-          std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
+      lambda::function<Try<T>(const std::string&)>(
+          lambda::bind(&parse<T>, lambda::_1)),
       name,
-      std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
-  flag.stringify = std::tr1::bind(&OptionStringifier<T>, option);
+      lambda::_2); // Use _2 because ignore FlagsBase*.
+  flag.stringify = lambda::bind(&OptionStringifier<T>, option);
 
   FlagsBase::add(flag);
 }
@@ -212,17 +211,17 @@ void FlagsBase::add(
   flag.name = name;
   flag.help = help;
   flag.boolean = typeid(T1) == typeid(bool);
-  flag.loader = std::tr1::bind(
+  flag.loader = lambda::bind(
       &MemberLoader<Flags, T1>::load,
-      std::tr1::placeholders::_1,
+      lambda::_1,
       t1,
-      std::tr1::function<Try<T1>(const std::string&)>(
-          std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
+      lambda::function<Try<T1>(const std::string&)>(
+          lambda::bind(&parse<T1>, lambda::_1)),
       name,
-      std::tr1::placeholders::_2);
-  flag.stringify = std::tr1::bind(
+      lambda::_2);
+  flag.stringify = lambda::bind(
       &MemberStringifier<Flags, T1>,
-      std::tr1::placeholders::_1,
+      lambda::_1,
       t1);
 
   // Update the help string to include the default value.
@@ -253,17 +252,17 @@ void FlagsBase::add(
   flag.name = name;
   flag.help = help;
   flag.boolean = typeid(T) == typeid(bool);
-  flag.loader = std::tr1::bind(
+  flag.loader = lambda::bind(
       &OptionMemberLoader<Flags, T>::load,
-      std::tr1::placeholders::_1,
+      lambda::_1,
       option,
-      std::tr1::function<Try<T>(const std::string&)>(
-          std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
+      lambda::function<Try<T>(const std::string&)>(
+          lambda::bind(&parse<T>, lambda::_1)),
       name,
-      std::tr1::placeholders::_2);
-  flag.stringify = std::tr1::bind(
+      lambda::_2);
+  flag.stringify = lambda::bind(
       &OptionMemberStringifier<Flags, T>,
-      std::tr1::placeholders::_1,
+      lambda::_1,
       option);
 
   add(flag);

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
index a6e0f58..f2e0eae 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
@@ -3,9 +3,8 @@
 
 #include <string>
 
-#include <tr1/functional>
-
 #include <stout/error.hpp>
+#include <stout/lambda.hpp>
 #include <stout/nothing.hpp>
 #include <stout/option.hpp>
 #include <stout/some.hpp>
@@ -23,7 +22,7 @@ struct Loader
 {
   static Try<Nothing> load(
       T* flag,
-      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const lambda::function<Try<T>(const std::string&)>& parse,
       const std::string& name,
       const std::string& value)
   {
@@ -43,7 +42,7 @@ struct OptionLoader
 {
   static Try<Nothing> load(
       Option<T>* flag,
-      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const lambda::function<Try<T>(const std::string&)>& parse,
       const std::string& name,
       const std::string& value)
   {
@@ -64,7 +63,7 @@ struct MemberLoader
   static Try<Nothing> load(
       FlagsBase* base,
       T F::*flag,
-      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const lambda::function<Try<T>(const std::string&)>& parse,
       const std::string& name,
       const std::string& value)
   {
@@ -88,7 +87,7 @@ struct OptionMemberLoader
   static Try<Nothing> load(
       FlagsBase* base,
       Option<T> F::*flag,
-      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const lambda::function<Try<T>(const std::string&)>& parse,
       const std::string& name,
       const std::string& value)
   {

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
index 4c5b297..bfa7b9c 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
@@ -4,8 +4,6 @@
 #include <sstream> // For istringstream.
 #include <string>
 
-#include <tr1/functional>
-
 #include <stout/duration.hpp>
 #include <stout/error.hpp>
 #include <stout/try.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
index 669218c..204c17e 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
@@ -3,8 +3,6 @@
 
 #include <string>
 
-#include <tr1/functional>
-
 #include <stout/error.hpp>
 #include <stout/nothing.hpp>
 #include <stout/option.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
index cae7fcb..c7623e7 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
@@ -6,7 +6,11 @@
 
 #include <string>
 
+#if __cplusplus >= 201103L
+#include <type_traits> // For 'is_pod'.
+#else // __cplusplus >= 201103L
 #include <tr1/type_traits> // For 'is_pod'.
+#endif // __cplusplus >= 201103L
 
 #include "error.hpp"
 #include "try.hpp"

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
index d493353..67b241d 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
@@ -1,14 +1,21 @@
 #ifndef __STOUT_LAMBDA_HPP__
 #define __STOUT_LAMBDA_HPP__
 
+#if __cplusplus >= 201103L
+namespace lambda {
+using std::bind;
+using std::function;
+using std::result_of;
+using namespace std::placeholders;
+} // namespace lambda {
+#else // __cplusplus >= 201103L
 #include <tr1/functional>
-
 namespace lambda {
-
 using std::tr1::bind;
 using std::tr1::function;
+using std::tr1::result_of;
 using namespace std::tr1::placeholders;
-
 } // namespace lambda {
+#endif // __cplusplus >= 201103L
 
 #endif // __STOUT_LAMBDA_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp
new file mode 100644
index 0000000..6e7ee43
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp
@@ -0,0 +1,17 @@
+#ifndef __STOUT_MEMORY_HPP__
+#define __STOUT_MEMORY_HPP__
+
+#if __cplusplus >= 201103L
+namespace memory {
+using std::shared_ptr;
+using std::weak_ptr;
+} // namespace memory {
+#else // __cplusplus >= 201103L
+#include <tr1/memory>
+namespace memory {
+using std::tr1::shared_ptr;
+using std::tr1::weak_ptr;
+} // namespace memory {
+#endif // __cplusplus >= 201103L
+
+#endif // __STOUT_MEMORY_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
index 838a5fe..72e4c1f 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
@@ -12,11 +12,10 @@
 #include <set>
 #include <string>
 
-#include <tr1/memory>
-
 #include <stout/error.hpp>
 #include <stout/exit.hpp>
 #include <stout/foreach.hpp>
+#include <stout/memory.hpp>
 #include <stout/option.hpp>
 #include <stout/os.hpp>
 #include <stout/stringify.hpp>
@@ -220,7 +219,7 @@ private:
       bool set; // Has this been initialized?
     };
 
-    std::tr1::shared_ptr<Memory> memory;
+    memory::shared_ptr<Memory> memory;
     std::vector<Tree> children;
   };
 
@@ -297,7 +296,7 @@ private:
     SharedMemoryDeleter deleter(fd);
 
     Tree tree;
-    tree.memory = std::tr1::shared_ptr<Tree::Memory>(
+    tree.memory = memory::shared_ptr<Tree::Memory>(
         (Tree::Memory*) memory, deleter);
     tree.memory->set = false;
 


[08/15] git commit: Added a patch for glog required when compiling with clang.

Posted by be...@apache.org.
Added a patch for glog required when compiling with clang.

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


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

Branch: refs/heads/master
Commit: a151dd9acab0c4ad15d77101a7000efd6ea315fe
Parents: 9bfbc2c
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:48:32 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:00:40 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/Makefile.am      |  17 +++-
 3rdparty/libprocess/3rdparty/glog-0.3.3.patch | 105 +++++++++++++++++++++
 2 files changed, 120 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a151dd9a/3rdparty/libprocess/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/Makefile.am b/3rdparty/libprocess/3rdparty/Makefile.am
index 068b17b..168ecea 100644
--- a/3rdparty/libprocess/3rdparty/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/Makefile.am
@@ -33,10 +33,18 @@ EXTRA_DIST =			\
   $(GMOCK).tar.gz		\
   $(GPERFTOOLS).tar.gz		\
   $(LIBEV).tar.gz		\
-  $(LIBEV).patch		\
   $(PROTOBUF).tar.gz		\
   $(RY_HTTP_PARSER).tar.gz
 
+# We need to patch glog in order to deal with a compilation issue when
+# compiling with clang (and C++11); see MESOS-860.
+EXTRA_DIST +=			\
+  $(GLOG).patch
+
+# We patch libev to keep it from reaping child processes.
+EXTRA_DIST +=			\
+  $(LIBEV).patch
+
 CLEAN_EXTRACTED =	\
   $(BOOST)		\
   $(GLOG)		\
@@ -75,6 +83,7 @@ libgmock_la_CPPFLAGS =			\
   -I$(GTEST)/include -I$(GTEST)		\
   -I$(GMOCK)/include -I$(GMOCK)
 
+
 # We list the sources in BUILT_SOURCES to make sure that the package
 # gets unarchived first.
 BUILT_SOURCES += $(nodist_libgmock_la_SOURCES)
@@ -85,8 +94,12 @@ $(GTEST)/src/gtest-all.cc: $(GMOCK)-stamp
 
 $(BOOST)/boost: $(BOOST)-stamp
 
+# NOTE: We explicitely set GTEST_CONFIG=no so that we don't attempt to
+# build glog against a system installed gtest (there's no reason to
+# "test" glog and it's highly likely it will cause a compilation bug
+# when building with clang).
 $(GLOG)/libglog.la: $(GLOG)-stamp
-	cd $(GLOG) && ./configure $(CONFIGURE_ARGS) && \
+	cd $(GLOG) && ./configure GTEST_CONFIG=no $(CONFIGURE_ARGS) && \
           $(MAKE) $(AM_MAKEFLAGS)
 
 if HAS_GPERFTOOLS

http://git-wip-us.apache.org/repos/asf/mesos/blob/a151dd9a/3rdparty/libprocess/3rdparty/glog-0.3.3.patch
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/glog-0.3.3.patch b/3rdparty/libprocess/3rdparty/glog-0.3.3.patch
new file mode 100644
index 0000000..2217103
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/glog-0.3.3.patch
@@ -0,0 +1,105 @@
+diff --git a/src/glog/stl_logging.h.in b/src/glog/stl_logging.h.in
+index 30836de..3e90573 100644
+--- a/src/glog/stl_logging.h.in
++++ b/src/glog/stl_logging.h.in
+@@ -50,10 +50,13 @@
+ #include <utility>
+ #include <vector>
+ 
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+ # include <ext/hash_set>
+ # include <ext/hash_map>
+ # include <ext/slist>
++#elif defined(_LIBCPP_VERSION)
++# include <unordered_map>
++# include <unordered_set>
+ #endif
+ 
+ // Forward declare these two, and define them after all the container streams
+@@ -80,7 +83,7 @@ inline std::ostream& operator<<(std::ostream& out, \
+ OUTPUT_TWO_ARG_CONTAINER(std::vector)
+ OUTPUT_TWO_ARG_CONTAINER(std::deque)
+ OUTPUT_TWO_ARG_CONTAINER(std::list)
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+ OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
+ #endif
+ 
+@@ -109,9 +112,12 @@ inline std::ostream& operator<<(std::ostream& out, \
+ 
+ OUTPUT_FOUR_ARG_CONTAINER(std::map)
+ OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+ OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
+ OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
++#elif defined(_LIBCPP_VERSION)
++OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set)
++OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset)
+ #endif
+ 
+ #undef OUTPUT_FOUR_ARG_CONTAINER
+@@ -124,9 +130,12 @@ inline std::ostream& operator<<(std::ostream& out, \
+   return out; \
+ }
+ 
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+ OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
+ OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
++#elif defined(_LIBCPP_VERSION)
++OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map)
++OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap)
+ #endif
+ 
+ #undef OUTPUT_FIVE_ARG_CONTAINER
+diff --git a/src/stl_logging_unittest.cc b/src/stl_logging_unittest.cc
+index 5dcbc44..ee344ca 100644
+--- a/src/stl_logging_unittest.cc
++++ b/src/stl_logging_unittest.cc
+@@ -39,7 +39,7 @@
+ #include <string>
+ #include <vector>
+ 
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+ # include <ext/hash_map>
+ # include <ext/hash_set>
+ #endif
+@@ -48,7 +48,7 @@
+ #include "googletest.h"
+ 
+ using namespace std;
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+ using namespace __gnu_cxx;
+ #endif
+ 
+@@ -83,7 +83,7 @@ void TestSTLLogging() {
+     CHECK_EQ(m, copied_m);  // This must compile.
+   }
+ 
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+   {
+     // Test a hashed simple associative container.
+     hash_set<int> hs;
+@@ -98,7 +98,7 @@ void TestSTLLogging() {
+   }
+ #endif
+ 
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+   {
+     // Test a hashed pair associative container.
+     hash_map<int, string> hm;
+@@ -145,7 +145,7 @@ void TestSTLLogging() {
+     CHECK_EQ(m, copied_m);  // This must compile.
+   }
+ 
+-#ifdef __GNUC__
++#if defined (__GNUC__) && !defined(_LIBCPP_VERSION)
+   {
+     // Test a hashed simple associative container.
+     // Use a user defined hash function.


[06/15] git commit: Replaced 'std::tr1' with 'lambda' and 'memory' in libprocess.

Posted by be...@apache.org.
Replaced 'std::tr1' with 'lambda' and 'memory' in libprocess.

Some fixes and enhancements were also made to the C++11 version of the
library. At this point libprocess can be compiled for C++11 and all
tests pass with gcc 4.8.

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


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

Branch: refs/heads/master
Commit: 89eec0581f954c26b0c37557cdf7b5266955e1a4
Parents: 7f16f83
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 22:10:36 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:00:38 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/async.hpp   |  52 +--
 .../libprocess/include/process/c++11/defer.hpp  | 256 ++++++++++++
 .../include/process/c++11/deferred.hpp          | 256 ++++++++++++
 .../libprocess/include/process/c++11/delay.hpp  |  87 ++++
 .../include/process/c++11/dispatch.hpp          | 398 +++++++++++++++++++
 .../include/process/c++11/executor.hpp          |  68 ++++
 3rdparty/libprocess/include/process/collect.hpp |   7 +-
 3rdparty/libprocess/include/process/defer.hpp   |   4 +
 .../libprocess/include/process/deferred.hpp     |   4 +
 3rdparty/libprocess/include/process/delay.hpp   |  66 +--
 .../libprocess/include/process/dispatch.hpp     | 201 +++++-----
 3rdparty/libprocess/include/process/event.hpp   |  10 +-
 .../libprocess/include/process/executor.hpp     |   4 +
 3rdparty/libprocess/include/process/future.hpp  | 186 +++++----
 3rdparty/libprocess/include/process/gmock.hpp   |   7 +-
 3rdparty/libprocess/include/process/process.hpp |  20 +-
 .../libprocess/include/process/protobuf.hpp     |   6 +-
 3rdparty/libprocess/include/process/run.hpp     |  28 +-
 3rdparty/libprocess/include/process/timer.hpp   |   9 +-
 3rdparty/libprocess/src/process.cpp             |  29 +-
 3rdparty/libprocess/src/tests/process_tests.cpp |  48 ++-
 3rdparty/libprocess/src/timer.cpp               |   9 +-
 22 files changed, 1433 insertions(+), 322 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/async.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/async.hpp b/3rdparty/libprocess/include/process/async.hpp
index 8fa2771..a7ac0cb 100644
--- a/3rdparty/libprocess/include/process/async.hpp
+++ b/3rdparty/libprocess/include/process/async.hpp
@@ -6,7 +6,7 @@
 #include <process/id.hpp>
 #include <process/process.hpp>
 
-#include <tr1/functional>
+#include <stout/lambda.hpp>
 
 namespace process {
 
@@ -26,7 +26,7 @@ private:
   AsyncExecutorProcess& operator = (const AsyncExecutorProcess&);
 
   template<typename F>
-  typename std::tr1::result_of<F(void)>::type execute(
+  typename lambda::result_of<F(void)>::type execute(
       const F& f)
   {
     terminate(self()); // Terminate this process after the function returns.
@@ -35,7 +35,7 @@ private:
 
   // TODO(vinod): Use boost macro enumerations.
   template<typename F, typename A1>
-  typename std::tr1::result_of<F(A1)>::type execute(
+  typename lambda::result_of<F(A1)>::type execute(
       const F& f, A1 a1)
   {
     terminate(self()); // Terminate this process after the function returns.
@@ -43,7 +43,7 @@ private:
   }
 
   template<typename F, typename A1, typename A2>
-  typename std::tr1::result_of<F(A1, A2)>::type execute(
+  typename lambda::result_of<F(A1, A2)>::type execute(
       const F& f, A1 a1, A2 a2)
   {
     terminate(self()); // Terminate this process after the function returns.
@@ -51,7 +51,7 @@ private:
   }
 
   template<typename F, typename A1, typename A2, typename A3>
-  typename std::tr1::result_of<F(A1, A2, A3)>::type execute(
+  typename lambda::result_of<F(A1, A2, A3)>::type execute(
       const F& f, A1 a1, A2 a2, A3 a3)
   {
     terminate(self()); // Terminate this process after the function returns.
@@ -59,7 +59,7 @@ private:
   }
 
   template<typename F, typename A1, typename A2, typename A3, typename A4>
-  typename std::tr1::result_of<F(A1, A2, A3, A4)>::type execute(
+  typename lambda::result_of<F(A1, A2, A3, A4)>::type execute(
       const F& f, A1 a1, A2 a2, A3 a3, A4 a4)
   {
     terminate(self()); // Terminate this process after the function returns.
@@ -74,23 +74,23 @@ class AsyncExecutor
 private:
   // Declare async functions as friends.
   template<typename F>
-  friend Future<typename std::tr1::result_of<F(void)>::type> async(
+  friend Future<typename lambda::result_of<F(void)>::type> async(
       const F& f);
 
   template<typename F, typename A1>
-  friend Future<typename std::tr1::result_of<F(A1)>::type> async(
+  friend Future<typename lambda::result_of<F(A1)>::type> async(
       const F& f, A1 a1);
 
   template<typename F, typename A1, typename A2>
-  friend Future<typename std::tr1::result_of<F(A1, A2)>::type> async(
+  friend Future<typename lambda::result_of<F(A1, A2)>::type> async(
       const F& f, A1 a1, A2 a2);
 
   template<typename F, typename A1, typename A2, typename A3>
-  friend Future<typename std::tr1::result_of<F(A1, A2, A3)>::type> async(
+  friend Future<typename lambda::result_of<F(A1, A2, A3)>::type> async(
       const F& f, A1 a1, A2 a2, A3 a3);
 
   template<typename F, typename A1, typename A2, typename A3, typename A4>
-  friend Future<typename std::tr1::result_of<F(A1, A2, A3, A4)>::type> async(
+  friend Future<typename lambda::result_of<F(A1, A2, A3, A4)>::type> async(
       const F& f, A1 a1, A2 a2, A3 a3, A4 a4);
 
   AsyncExecutor()
@@ -106,11 +106,11 @@ private:
   AsyncExecutor& operator = (const AsyncExecutor&);
 
   template<typename F>
-  Future<typename std::tr1::result_of<F(void)>::type> execute(
+  Future<typename lambda::result_of<F(void)>::type> execute(
       const F& f)
   {
     // Necessary to disambiguate.
-    typedef typename std::tr1::result_of<F(void)>::type
+    typedef typename lambda::result_of<F(void)>::type
         (AsyncExecutorProcess::*R)(const F&);
 
     return dispatch(process,
@@ -120,11 +120,11 @@ private:
 
   // TODO(vinod): Use boost macro enumerations.
   template<typename F, typename A1>
-  Future<typename std::tr1::result_of<F(A1)>::type> execute(
+  Future<typename lambda::result_of<F(A1)>::type> execute(
       const F& f, A1 a1)
   {
     // Necessary to disambiguate.
-    typedef typename std::tr1::result_of<F(A1)>::type
+    typedef typename lambda::result_of<F(A1)>::type
         (AsyncExecutorProcess::*R)(const F&, A1);
 
     return dispatch(process,
@@ -134,11 +134,11 @@ private:
   }
 
   template<typename F, typename A1, typename A2>
-  Future<typename std::tr1::result_of<F(A1, A2)>::type> execute(
+  Future<typename lambda::result_of<F(A1, A2)>::type> execute(
       const F& f, A1 a1, A2 a2)
   {
     // Necessary to disambiguate.
-    typedef typename std::tr1::result_of<F(A1, A2)>::type
+    typedef typename lambda::result_of<F(A1, A2)>::type
         (AsyncExecutorProcess::*R)(const F&, A1, A2);
 
     return dispatch(process,
@@ -149,11 +149,11 @@ private:
   }
 
   template<typename F, typename A1, typename A2, typename A3>
-  Future<typename std::tr1::result_of<F(A1, A2, A3)>::type> execute(
+  Future<typename lambda::result_of<F(A1, A2, A3)>::type> execute(
       const F& f, A1 a1, A2 a2, A3 a3)
   {
     // Necessary to disambiguate.
-    typedef typename std::tr1::result_of<F(A1, A2, A3)>::type
+    typedef typename lambda::result_of<F(A1, A2, A3)>::type
         (AsyncExecutorProcess::*R)(const F&, A1, A2, A3);
 
     return dispatch(process,
@@ -165,11 +165,11 @@ private:
   }
 
   template<typename F, typename A1, typename A2, typename A3, typename A4>
-  Future<typename std::tr1::result_of<F(A1, A2, A3, A4)>::type> execute(
+  Future<typename lambda::result_of<F(A1, A2, A3, A4)>::type> execute(
       const F& f, A1 a1, A2 a2, A3 a3, A4 a4)
   {
     // Necessary to disambiguate.
-    typedef typename std::tr1::result_of<F(A1, A2, A3, A4)>::type
+    typedef typename lambda::result_of<F(A1, A2, A3, A4)>::type
         (AsyncExecutorProcess::*R)(const F&, A1, A2, A3, A4);
 
     return dispatch(process,
@@ -188,7 +188,7 @@ private:
 // Provides an abstraction for asynchronously executing a function.
 // TODO(vinod): Use boost macro to enumerate arguments/params.
 template<typename F>
-Future<typename std::tr1::result_of<F(void)>::type>
+Future<typename lambda::result_of<F(void)>::type>
     async(const F& f)
 {
   return AsyncExecutor().execute(f);
@@ -196,7 +196,7 @@ Future<typename std::tr1::result_of<F(void)>::type>
 
 
 template<typename F, typename A1>
-Future<typename std::tr1::result_of<F(A1)>::type>
+Future<typename lambda::result_of<F(A1)>::type>
     async(const F& f, A1 a1)
 {
   return AsyncExecutor().execute(f, a1);
@@ -204,7 +204,7 @@ Future<typename std::tr1::result_of<F(A1)>::type>
 
 
 template<typename F, typename A1, typename A2>
-Future<typename std::tr1::result_of<F(A1, A2)>::type>
+Future<typename lambda::result_of<F(A1, A2)>::type>
     async(const F& f, A1 a1, A2 a2)
 {
   return AsyncExecutor().execute(f, a1, a2);
@@ -212,7 +212,7 @@ Future<typename std::tr1::result_of<F(A1, A2)>::type>
 
 
 template<typename F, typename A1, typename A2, typename A3>
-Future<typename std::tr1::result_of<F(A1, A2, A3)>::type>
+Future<typename lambda::result_of<F(A1, A2, A3)>::type>
     async(const F& f, A1 a1, A2 a2, A3 a3)
 {
   return AsyncExecutor().execute(f, a1, a2, a3);
@@ -220,7 +220,7 @@ Future<typename std::tr1::result_of<F(A1, A2, A3)>::type>
 
 
 template<typename F, typename A1, typename A2, typename A3, typename A4>
-Future<typename std::tr1::result_of<F(A1, A2, A3, A4)>::type>
+Future<typename lambda::result_of<F(A1, A2, A3, A4)>::type>
     async(const F& f, A1 a1, A2 a2, A3 a3, A4 a4)
 {
   return AsyncExecutor().execute(f, a1, a2, a3, a4);

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/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
new file mode 100644
index 0000000..27b0643
--- /dev/null
+++ b/3rdparty/libprocess/include/process/c++11/defer.hpp
@@ -0,0 +1,256 @@
+#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.
+#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))>(), ENUM_PARAMS(N, a)))> \
+  {                                                                     \
+    return std::bind(std::function<void(ENUM_PARAMS(N, P))>(            \
+        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
+          dispatch(pid, method, ENUM_PARAMS(N, p));                     \
+        }), 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));            \
+  }                                                                     \
+                                                                        \
+  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))>(), ENUM_PARAMS(N, a)))> \
+  {                                                                     \
+    return std::bind(std::function<Future<R>(ENUM_PARAMS(N, P))>(       \
+        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
+          return dispatch(pid, method, ENUM_PARAMS(N, p));              \
+        }), 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));            \
+  }                                                                     \
+                                                                        \
+  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))>(), ENUM_PARAMS(N, a)))> \
+  {                                                                     \
+    return std::bind(std::function<Future<R>(ENUM_PARAMS(N, P))>(       \
+        [=] (ENUM_BINARY_PARAMS(N, P, p)) {                             \
+          return dispatch(pid, method, ENUM_PARAMS(N, p));              \
+        }), 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));            \
+  }                                                                     \
+                                                                        \
+  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, f);
+}
+
+
+template <typename F>
+_Deferred<F> defer(F f)
+{
+  if (__process__ != NULL) {
+    return defer(__process__->self(), f);
+  }
+
+  return __executor__->defer(f);
+}
+
+} // namespace process {
+
+#endif // __PROCESS_DEFER_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/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
new file mode 100644
index 0000000..06e67cf
--- /dev/null
+++ b/3rdparty/libprocess/include/process/c++11/deferred.hpp
@@ -0,0 +1,256 @@
+#ifndef __PROCESS_DEFERRED_HPP__
+#define __PROCESS_DEFERRED_HPP__
+
+#include <functional>
+
+#include <process/dispatch.hpp>
+#include <process/future.hpp>
+#include <process/pid.hpp>
+
+#include <stout/preprocessor.hpp>
+
+namespace process {
+
+// Forward declarations (removing these produces cryptic compiler
+// errors even though we are just using them to declare friends).
+class Executor;
+template <typename G> struct _Deferred;
+
+
+// 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));
+
+  Deferred(const std::function<F>& f) : std::function<F>(f) {}
+};
+
+
+template <typename F>
+struct _Deferred
+{
+  operator Deferred<void()> () const
+  {
+    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_));
+        });
+  }
+
+#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);
+
+  template <typename G>
+  friend _Deferred<G> defer(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))>(), ENUM_PARAMS(N, a)))>;
+
+  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))>(), ENUM_PARAMS(N, a)))>;
+
+  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))>(), ENUM_PARAMS(N, a)))>;
+
+  REPEAT_FROM_TO(1, 11, TEMPLATE, _) // Args A0 -> A9.
+#undef TEMPLATE
+
+  _Deferred(UPID pid, F f) : pid(pid), f(f) {}
+  _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/89eec058/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
new file mode 100644
index 0000000..5f686db
--- /dev/null
+++ b/3rdparty/libprocess/include/process/c++11/delay.hpp
@@ -0,0 +1,87 @@
+#ifndef __PROCESS_DELAY_HPP__
+#define __PROCESS_DELAY_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 Timer::create(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 Timer::create(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/89eec058/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
new file mode 100644
index 0000000..76da282
--- /dev/null
+++ b/3rdparty/libprocess/include/process/c++11/dispatch.hpp
@@ -0,0 +1,398 @@
+#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 std::string& method = std::string());
+
+
+// Canonicalizes a pointer to a member function (i.e., method) into a
+// bytes representation for comparison (e.g., in tests).
+template <typename Method>
+std::string canonicalize(Method method)
+{
+  return std::string(reinterpret_cast<const char*>(&method), sizeof(method));
+}
+
+} // 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, internal::canonicalize(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, internal::canonicalize(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, internal::canonicalize(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, internal::canonicalize(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, internal::canonicalize(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, internal::canonicalize(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/89eec058/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
new file mode 100644
index 0000000..c6c9032
--- /dev/null
+++ b/3rdparty/libprocess/include/process/c++11/executor.hpp
@@ -0,0 +1,68 @@
+#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(), 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/89eec058/3rdparty/libprocess/include/process/collect.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/collect.hpp b/3rdparty/libprocess/include/process/collect.hpp
index 27e2729..ff8ab34 100644
--- a/3rdparty/libprocess/include/process/collect.hpp
+++ b/3rdparty/libprocess/include/process/collect.hpp
@@ -11,6 +11,7 @@
 #include <process/process.hpp>
 #include <process/timeout.hpp>
 
+#include <stout/lambda.hpp>
 #include <stout/none.hpp>
 #include <stout/option.hpp>
 
@@ -69,8 +70,7 @@ public:
 
     typename std::list<Future<T> >::const_iterator iterator;
     for (iterator = futures.begin(); iterator != futures.end(); ++iterator) {
-      (*iterator).onAny(
-          defer(this, &CollectProcess::waited, std::tr1::placeholders::_1));
+      (*iterator).onAny(defer(this, &CollectProcess::waited, lambda::_1));
     }
   }
 
@@ -153,8 +153,7 @@ public:
 
     typename std::list<Future<T> >::const_iterator iterator;
     for (iterator = futures.begin(); iterator != futures.end(); ++iterator) {
-      (*iterator).onAny(
-          defer(this, &AwaitProcess::waited, std::tr1::placeholders::_1));
+      (*iterator).onAny(defer(this, &AwaitProcess::waited, lambda::_1));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/defer.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/defer.hpp b/3rdparty/libprocess/include/process/defer.hpp
index 1eb770b..dc2ec3b 100644
--- a/3rdparty/libprocess/include/process/defer.hpp
+++ b/3rdparty/libprocess/include/process/defer.hpp
@@ -1,3 +1,6 @@
+#if __cplusplus >= 201103L
+#include <process/c++11/defer.hpp>
+#else
 #ifndef __PROCESS_DEFER_HPP__
 #define __PROCESS_DEFER_HPP__
 
@@ -436,3 +439,4 @@ inline Deferred<void(void)> defer(const std::tr1::function<void(void)>& f)
 } // namespace process {
 
 #endif // __PROCESS_DEFER_HPP__
+#endif // __cplusplus >= 201103L

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/deferred.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/deferred.hpp b/3rdparty/libprocess/include/process/deferred.hpp
index 8907e80..a25080f 100644
--- a/3rdparty/libprocess/include/process/deferred.hpp
+++ b/3rdparty/libprocess/include/process/deferred.hpp
@@ -1,3 +1,6 @@
+#if __cplusplus >= 201103L
+#include <process/c++11/deferred.hpp>
+#else
 #ifndef __PROCESS_DEFERRED_HPP__
 #define __PROCESS_DEFERRED_HPP__
 
@@ -134,3 +137,4 @@ private:
 } // namespace process {
 
 #endif // __PROCESS_DEFERRED_HPP__
+#endif // __cplusplus >= 201103L

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/delay.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/delay.hpp b/3rdparty/libprocess/include/process/delay.hpp
index 97acd76..487f652 100644
--- a/3rdparty/libprocess/include/process/delay.hpp
+++ b/3rdparty/libprocess/include/process/delay.hpp
@@ -1,12 +1,15 @@
+#if __cplusplus >= 201103L
+#include <process/c++11/delay.hpp>
+#else
 #ifndef __PROCESS_DELAY_HPP__
 #define __PROCESS_DELAY_HPP__
 
-#include <tr1/functional>
-
 #include <process/dispatch.hpp>
 #include <process/timer.hpp>
 
 #include <stout/duration.hpp>
+#include <stout/lambda.hpp>
+#include <stout/memory.hpp>
 #include <stout/preprocessor.hpp>
 
 namespace process {
@@ -21,21 +24,21 @@ Timer delay(const Duration& duration,
             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,
-                   internal::canonicalize(method));
+  memory::shared_ptr<lambda::function<void(T*)> > thunk(
+      new lambda::function<void(T*)>(
+          lambda::bind(method, lambda::_1)));
+
+  memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher(
+      new lambda::function<void(ProcessBase*)>(
+          lambda::bind(&internal::vdispatcher<T>,
+                       lambda::_1,
+                       thunk)));
+
+  lambda::function<void(void)> dispatch =
+    lambda::bind(internal::dispatch,
+                 pid,
+                 dispatcher,
+                 internal::canonicalize(method));
 
   return Timer::create(duration, dispatch);
 }
@@ -68,23 +71,21 @@ Timer delay(const Duration& duration,
               void (T::*method)(ENUM_PARAMS(N, P)),                     \
               ENUM_BINARY_PARAMS(N, A, a))                              \
   {                                                                     \
-    std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk(          \
-        new std::tr1::function<void(T*)>(                               \
-            std::tr1::bind(method,                                      \
-                           std::tr1::placeholders::_1,                  \
-                           ENUM_PARAMS(N, a))));                        \
+    memory::shared_ptr<lambda::function<void(T*)> > thunk(              \
+        new lambda::function<void(T*)>(                                 \
+            lambda::bind(method, lambda::_1, ENUM_PARAMS(N, a))));      \
                                                                         \
-    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)));                                    \
+    memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher( \
+        new lambda::function<void(ProcessBase*)>(                       \
+            lambda::bind(&internal::vdispatcher<T>,                     \
+                         lambda::_1,                                    \
+                         thunk)));                                      \
                                                                         \
-    std::tr1::function<void(void)> dispatch =                           \
-      std::tr1::bind(internal::dispatch,                                \
-                     pid,                                               \
-                     dispatcher,                                        \
-                     internal::canonicalize(method));                   \
+    lambda::function<void(void)> dispatch =                             \
+      lambda::bind(internal::dispatch,                                  \
+                   pid,                                                 \
+                   dispatcher,                                          \
+                   internal::canonicalize(method));                     \
                                                                         \
     return Timer::create(duration, dispatch);                           \
   }                                                                     \
@@ -117,3 +118,4 @@ Timer delay(const Duration& duration,
 } // namespace process {
 
 #endif // __PROCESS_DELAY_HPP__
+#endif // __cplusplus >= 201103L

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/dispatch.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/dispatch.hpp b/3rdparty/libprocess/include/process/dispatch.hpp
index b337a87..88570f7 100644
--- a/3rdparty/libprocess/include/process/dispatch.hpp
+++ b/3rdparty/libprocess/include/process/dispatch.hpp
@@ -1,13 +1,15 @@
+#if __cplusplus >= 201103L
+#include <process/c++11/dispatch.hpp>
+#else
 #ifndef __PROCESS_DISPATCH_HPP__
 #define __PROCESS_DISPATCH_HPP__
 
 #include <string>
 
-#include <tr1/functional>
-#include <tr1/memory> // TODO(benh): Replace all shared_ptr with unique_ptr.
-
 #include <process/process.hpp>
 
+#include <stout/lambda.hpp>
+#include <stout/memory.hpp> // TODO(benh): Replace shared_ptr with unique_ptr.
 #include <stout/preprocessor.hpp>
 
 namespace process {
@@ -51,7 +53,7 @@ namespace internal {
 // will probably change in the future to unique_ptr (or a variant).
 void dispatch(
     const UPID& pid,
-    const std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> >& f,
+    const memory::shared_ptr<lambda::function<void(ProcessBase*)> >& f,
     const std::string& method = std::string());
 
 // For each return type (void, future, value) there is a dispatcher
@@ -65,7 +67,7 @@ void dispatch(
 template <typename T>
 void vdispatcher(
     ProcessBase* process,
-    std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk)
+    memory::shared_ptr<lambda::function<void(T*)> > thunk)
 {
   assert(process != NULL);
   T* t = dynamic_cast<T*>(process);
@@ -77,8 +79,8 @@ void vdispatcher(
 template <typename R, typename T>
 void pdispatcher(
     ProcessBase* process,
-    std::tr1::shared_ptr<std::tr1::function<Future<R>(T*)> > thunk,
-    std::tr1::shared_ptr<Promise<R> > promise)
+    memory::shared_ptr<lambda::function<Future<R>(T*)> > thunk,
+    memory::shared_ptr<Promise<R> > promise)
 {
   assert(process != NULL);
   T* t = dynamic_cast<T*>(process);
@@ -90,8 +92,8 @@ void pdispatcher(
 template <typename R, typename T>
 void rdispatcher(
     ProcessBase* process,
-    std::tr1::shared_ptr<std::tr1::function<R(T*)> > thunk,
-    std::tr1::shared_ptr<Promise<R> > promise)
+    memory::shared_ptr<lambda::function<R(T*)> > thunk,
+    memory::shared_ptr<Promise<R> > promise)
 {
   assert(process != NULL);
   T* t = dynamic_cast<T*>(process);
@@ -125,17 +127,17 @@ std::string canonicalize(Method method)
 //     void (T::*method)(P...),
 //     P... p)
 // {
-//   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::forward<P>(p)...)));
+//   memory::shared_ptr<lambda::function<void(T*)> > thunk(
+//       new lambda::function<void(T*)>(
+//           lambda::bind(method,
+//                        lambda::_1,
+//                        std::forward<P>(p)...)));
 //
-//   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)));
+//   memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher(
+//       new lambda::function<void(ProcessBase*)>(
+//           lambda::bind(&internal::vdispatcher<T>,
+//                        lambda::_1,
+//                        thunk)));
 //
 //   internal::dispatch(pid, dispatcher, internal::canonicalize(method));
 // }
@@ -145,15 +147,15 @@ void dispatch(
     const PID<T>& pid,
     void (T::*method)(void))
 {
-  std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk(
-      new std::tr1::function<void(T*)>(
-          std::tr1::bind(method, std::tr1::placeholders::_1)));
+  memory::shared_ptr<lambda::function<void(T*)> > thunk(
+      new lambda::function<void(T*)>(
+          lambda::bind(method, lambda::_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)));
+  memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher(
+      new lambda::function<void(ProcessBase*)>(
+          lambda::bind(&internal::vdispatcher<T>,
+                       lambda::_1,
+                       thunk)));
 
   internal::dispatch(pid, dispatcher, internal::canonicalize(method));
 }
@@ -183,17 +185,17 @@ void dispatch(
       void (T::*method)(ENUM_PARAMS(N, P)),                             \
       ENUM_BINARY_PARAMS(N, A, a))                                      \
   {                                                                     \
-    std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk(          \
-        new std::tr1::function<void(T*)>(                               \
-            std::tr1::bind(method,                                      \
-                           std::tr1::placeholders::_1,                  \
-                           ENUM_PARAMS(N, a))));                        \
+    memory::shared_ptr<lambda::function<void(T*)> > thunk(              \
+        new lambda::function<void(T*)>(                                 \
+            lambda::bind(method,                                        \
+                         lambda::_1,                                    \
+                         ENUM_PARAMS(N, a))));                          \
                                                                         \
-    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)));                                    \
+    memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher( \
+        new lambda::function<void(ProcessBase*)>(                       \
+            lambda::bind(&internal::vdispatcher<T>,                     \
+                         lambda::_1,                                    \
+                         thunk)));                                      \
                                                                         \
     internal::dispatch(pid, dispatcher, internal::canonicalize(method)); \
   }                                                                     \
@@ -232,20 +234,20 @@ void dispatch(
 //     Future<R> (T::*method)(P...),
 //     P... p)
 // {
-//   std::tr1::shared_ptr<std::tr1::function<Future<R>(T*)> > thunk(
-//       new std::tr1::function<Future<R>(T*)>(
-//           std::tr1::bind(method,
-//                          std::tr1::placeholders::_1,
-//                          std::forward<P>(p)...)));
+//   memory::shared_ptr<lambda::function<Future<R>(T*)> > thunk(
+//       new lambda::function<Future<R>(T*)>(
+//           lambda::bind(method,
+//                        lambda::_1,
+//                        std::forward<P>(p)...)));
 //
-//   std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());
+//   memory::shared_ptr<Promise<R> > promise(new Promise<R>());
 //   Future<R> future = promise->future();
 //
-//   std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-//       new std::tr1::function<void(ProcessBase*)>(
-//           std::tr1::bind(&internal::pdispatcher<R, T>,
-//                          std::tr1::placeholders::_1,
-//                          thunk, promise)));
+//   memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher(
+//       new lambda::function<void(ProcessBase*)>(
+//           lambda::bind(&internal::pdispatcher<R, T>,
+//                        lambda::_1,
+//                        thunk, promise)));
 //
 //   internal::dispatch(pid, dispatcher, internal::canonicalize(method));
 //
@@ -257,18 +259,18 @@ Future<R> dispatch(
     const PID<T>& pid,
     Future<R> (T::*method)(void))
 {
-  std::tr1::shared_ptr<std::tr1::function<Future<R>(T*)> > thunk(
-      new std::tr1::function<Future<R>(T*)>(
-          std::tr1::bind(method, std::tr1::placeholders::_1)));
+  memory::shared_ptr<lambda::function<Future<R>(T*)> > thunk(
+      new lambda::function<Future<R>(T*)>(
+          lambda::bind(method, lambda::_1)));
 
-  std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());
+  memory::shared_ptr<Promise<R> > promise(new Promise<R>());
   Future<R> future = promise->future();
 
-  std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-      new std::tr1::function<void(ProcessBase*)>(
-          std::tr1::bind(&internal::pdispatcher<R, T>,
-                         std::tr1::placeholders::_1,
-                         thunk, promise)));
+  memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher(
+      new lambda::function<void(ProcessBase*)>(
+          lambda::bind(&internal::pdispatcher<R, T>,
+                       lambda::_1,
+                       thunk, promise)));
 
   internal::dispatch(pid, dispatcher, internal::canonicalize(method));
 
@@ -301,20 +303,20 @@ Future<R> dispatch(
       Future<R> (T::*method)(ENUM_PARAMS(N, P)),                        \
       ENUM_BINARY_PARAMS(N, A, a))                                      \
   {                                                                     \
-    std::tr1::shared_ptr<std::tr1::function<Future<R>(T*)> > thunk(     \
-        new std::tr1::function<Future<R>(T*)>(                          \
-            std::tr1::bind(method,                                      \
-                           std::tr1::placeholders::_1,                  \
-                           ENUM_PARAMS(N, a))));                        \
+    memory::shared_ptr<lambda::function<Future<R>(T*)> > thunk(         \
+        new lambda::function<Future<R>(T*)>(                            \
+            lambda::bind(method,                                        \
+                         lambda::_1,                                    \
+                         ENUM_PARAMS(N, a))));                          \
                                                                         \
-    std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());        \
+    memory::shared_ptr<Promise<R> > promise(new Promise<R>());          \
     Future<R> future = promise->future();                               \
                                                                         \
-    std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher( \
-        new std::tr1::function<void(ProcessBase*)>(                     \
-            std::tr1::bind(&internal::pdispatcher<R, T>,                \
-                           std::tr1::placeholders::_1,                  \
-                           thunk, promise)));                           \
+    memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher( \
+        new lambda::function<void(ProcessBase*)>(                       \
+            lambda::bind(&internal::pdispatcher<R, T>,                  \
+                         lambda::_1,                                    \
+                         thunk, promise)));                             \
                                                                         \
     internal::dispatch(pid, dispatcher, internal::canonicalize(method)); \
                                                                         \
@@ -357,20 +359,20 @@ Future<R> dispatch(
 //     R (T::*method)(P...),
 //     P... p)
 // {
-//   std::tr1::shared_ptr<std::tr1::function<R(T*)> > thunk(
-//       new std::tr1::function<R(T*)>(
-//           std::tr1::bind(method,
-//                          std::tr1::placeholders::_1,
-//                          std::forward<P>(p)...)));
+//   memory::shared_ptr<lambda::function<R(T*)> > thunk(
+//       new lambda::function<R(T*)>(
+//           lambda::bind(method,
+//                        lambda::_1,
+//                        std::forward<P>(p)...)));
 //
-//   std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());
+//   memory::shared_ptr<Promise<R> > promise(new Promise<R>());
 //   Future<R> future = promise->future();
 //
-//   std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-//       new std::tr1::function<void(ProcessBase*)>(
-//           std::tr1::bind(&internal::rdispatcher<R, T>,
-//                          std::tr1::placeholders::_1,
-//                          thunk, promise)));
+//   memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher(
+//       new lambda::function<void(ProcessBase*)>(
+//           lambda::bind(&internal::rdispatcher<R, T>,
+//                        lambda::_1,
+//                        thunk, promise)));
 //
 //   internal::dispatch(pid, dispatcher, internal::canonicalize(method));
 //
@@ -382,18 +384,18 @@ Future<R> dispatch(
     const PID<T>& pid,
     R (T::*method)(void))
 {
-  std::tr1::shared_ptr<std::tr1::function<R(T*)> > thunk(
-      new std::tr1::function<R(T*)>(
-          std::tr1::bind(method, std::tr1::placeholders::_1)));
+  memory::shared_ptr<lambda::function<R(T*)> > thunk(
+      new lambda::function<R(T*)>(
+          lambda::bind(method, lambda::_1)));
 
-  std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());
+  memory::shared_ptr<Promise<R> > promise(new Promise<R>());
   Future<R> future = promise->future();
 
-  std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher(
-      new std::tr1::function<void(ProcessBase*)>(
-          std::tr1::bind(&internal::rdispatcher<R, T>,
-                         std::tr1::placeholders::_1,
-                         thunk, promise)));
+  memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher(
+      new lambda::function<void(ProcessBase*)>(
+          lambda::bind(&internal::rdispatcher<R, T>,
+                       lambda::_1,
+                       thunk, promise)));
 
   internal::dispatch(pid, dispatcher, internal::canonicalize(method));
 
@@ -426,20 +428,20 @@ Future<R> dispatch(
       R (T::*method)(ENUM_PARAMS(N, P)),                                \
       ENUM_BINARY_PARAMS(N, A, a))                                      \
   {                                                                     \
-    std::tr1::shared_ptr<std::tr1::function<R(T*)> > thunk(             \
-        new std::tr1::function<R(T*)>(                                  \
-            std::tr1::bind(method,                                      \
-                           std::tr1::placeholders::_1,                  \
-                           ENUM_PARAMS(N, a))));                        \
+    memory::shared_ptr<lambda::function<R(T*)> > thunk(                 \
+        new lambda::function<R(T*)>(                                    \
+            lambda::bind(method,                                        \
+                         lambda::_1,                                    \
+                         ENUM_PARAMS(N, a))));                          \
                                                                         \
-    std::tr1::shared_ptr<Promise<R> > promise(new Promise<R>());        \
+    memory::shared_ptr<Promise<R> > promise(new Promise<R>());          \
     Future<R> future = promise->future();                               \
                                                                         \
-    std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher( \
-        new std::tr1::function<void(ProcessBase*)>(                     \
-            std::tr1::bind(&internal::rdispatcher<R, T>,                \
-                           std::tr1::placeholders::_1,                  \
-                           thunk, promise)));                           \
+    memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher( \
+        new lambda::function<void(ProcessBase*)>(                       \
+            lambda::bind(&internal::rdispatcher<R, T>,                  \
+                         lambda::_1,                                    \
+                         thunk, promise)));                             \
                                                                         \
     internal::dispatch(pid, dispatcher, internal::canonicalize(method)); \
                                                                         \
@@ -476,3 +478,4 @@ Future<R> dispatch(
 } // namespace process {
 
 #endif // __PROCESS_DISPATCH_HPP__
+#endif // __cplusplus >= 201103L

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/event.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/event.hpp b/3rdparty/libprocess/include/process/event.hpp
index cf728da..ca407ec 100644
--- a/3rdparty/libprocess/include/process/event.hpp
+++ b/3rdparty/libprocess/include/process/event.hpp
@@ -1,14 +1,14 @@
 #ifndef __PROCESS_EVENT_HPP__
 #define __PROCESS_EVENT_HPP__
 
-#include <tr1/functional>
-#include <tr1/memory> // TODO(benh): Replace all shared_ptr with unique_ptr.
-
 #include <process/future.hpp>
 #include <process/http.hpp>
 #include <process/message.hpp>
 #include <process/socket.hpp>
 
+#include <stout/lambda.hpp>
+#include <stout/memory.hpp> // TODO(benh): Replace shared_ptr with unique_ptr.
+
 namespace process {
 
 // Forward declarations.
@@ -124,7 +124,7 @@ struct DispatchEvent : Event
 {
   DispatchEvent(
       const UPID& _pid,
-      const std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> >& _f,
+      const memory::shared_ptr<lambda::function<void(ProcessBase*)> >& _f,
       const std::string& _method)
     : pid(_pid),
       f(_f),
@@ -140,7 +140,7 @@ struct DispatchEvent : Event
   const UPID pid;
 
   // Function to get invoked as a result of this dispatch event.
-  const std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > f;
+  const memory::shared_ptr<lambda::function<void(ProcessBase*)> > f;
 
   // Canonical "byte" representation of a pointer to a member function
   // (i.e., method) encapsulated in the above function (or empty if

http://git-wip-us.apache.org/repos/asf/mesos/blob/89eec058/3rdparty/libprocess/include/process/executor.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/executor.hpp b/3rdparty/libprocess/include/process/executor.hpp
index f203476..4ce0a21 100644
--- a/3rdparty/libprocess/include/process/executor.hpp
+++ b/3rdparty/libprocess/include/process/executor.hpp
@@ -1,3 +1,6 @@
+#if __cplusplus >= 201103L
+#include <process/c++11/executor.hpp>
+#else
 #ifndef __PROCESS_EXECUTOR_HPP__
 #define __PROCESS_EXECUTOR_HPP__
 
@@ -258,3 +261,4 @@ extern ThreadLocal<Executor>* _executor_;
 } // namespace process {
 
 #endif // __PROCESS_EXECUTOR_HPP__
+#endif // __cplusplus >= 201103L


[07/15] git commit: Replaced 'std::tr1' with 'lambda' and 'memory' in Mesos.

Posted by be...@apache.org.
Replaced 'std::tr1' with 'lambda' and 'memory' in Mesos.

At this point we can compile Mesos for C++11 with gcc 4.8.

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


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

Branch: refs/heads/master
Commit: 70aeb47d05c9689cc3406b4f129d8f3456bfd6a8
Parents: 89eec05
Author: Benjamin Hindman <be...@gmail.com>
Authored: Mon Dec 30 11:30:07 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Jan 14 12:00:39 2014 -0800

----------------------------------------------------------------------
 src/Makefile.am                      |  4 ++--
 src/common/thread.hpp                | 10 +++++-----
 src/examples/long_lived_executor.cpp |  9 ++++-----
 src/master/detector.cpp              |  3 ---
 src/master/http.cpp                  |  5 +++--
 src/master/master.cpp                |  5 +++--
 src/master/master.hpp                |  5 ++---
 src/slave/slave.hpp                  |  2 --
 src/tests/zookeeper.cpp              |  4 +---
 src/tests/zookeeper.hpp              |  4 +---
 10 files changed, 21 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 150aafb..4f04dc6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -748,8 +748,8 @@ $(MESOS_EGG): python/setup.py $(srcdir)/python/src/mesos.py		\
 	  $(MKDIR_P) python/src;					\
 	  cp -pf $(srcdir)/python/src/mesos.py python/src;		\
 	fi
-	@LIBS="$(LIBS)" PYTHONPATH=$(DISTRIBUTE_EGG)			\
-	  $(PYTHON) python/setup.py bdist_egg
+	@LIBS="$(LIBS)" CC="$(CC)" CXX="$(CXX)"				\
+	  PYTHONPATH=$(DISTRIBUTE_EGG) $(PYTHON) python/setup.py bdist_egg
 
 CLEANFILES += $(MESOS_EGG) python/build/temp.*/native/*.o python/build/lib.*/*
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/common/thread.hpp
----------------------------------------------------------------------
diff --git a/src/common/thread.hpp b/src/common/thread.hpp
index 7808b81..7e48724 100644
--- a/src/common/thread.hpp
+++ b/src/common/thread.hpp
@@ -3,7 +3,7 @@
 
 #include <pthread.h>
 
-#include <tr1/functional>
+#include <stout/lambda.hpp>
 
 // Provides a simple threading facility for starting a thread to run
 // an arbitrary function. No mechanism for returning a value from the
@@ -14,17 +14,17 @@ namespace thread {
 
 void* __run(void* arg)
 {
-  std::tr1::function<void(void)>* function =
-    reinterpret_cast<std::tr1::function<void(void)>*>(arg);
+  lambda::function<void(void)>* function =
+    reinterpret_cast<lambda::function<void(void)>*>(arg);
   (*function)();
   delete function;
   return 0;
 }
 
 
-bool start(const std::tr1::function<void(void)>& f, bool detach = false)
+bool start(const lambda::function<void(void)>& f, bool detach = false)
 {
-  std::tr1::function<void(void)>* __f = new std::tr1::function<void(void)>(f);
+  lambda::function<void(void)>* __f = new lambda::function<void(void)>(f);
 
   pthread_t t;
   if (pthread_create(&t, NULL, __run, __f) != 0) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/examples/long_lived_executor.cpp
----------------------------------------------------------------------
diff --git a/src/examples/long_lived_executor.cpp b/src/examples/long_lived_executor.cpp
index 3fcee6c..d9b7fa1 100644
--- a/src/examples/long_lived_executor.cpp
+++ b/src/examples/long_lived_executor.cpp
@@ -22,11 +22,10 @@
 #include <cstdlib>
 #include <iostream>
 
-#include <tr1/functional>
-
 #include <mesos/executor.hpp>
 
 #include <stout/duration.hpp>
+#include <stout/lambda.hpp>
 #include <stout/os.hpp>
 
 using namespace mesos;
@@ -50,7 +49,7 @@ void run(ExecutorDriver* driver, const TaskInfo& task)
 
 void* start(void* arg)
 {
-  std::tr1::function<void(void)>* thunk = (std::tr1::function<void(void)>*) arg;
+  lambda::function<void(void)>* thunk = (lambda::function<void(void)>*) arg;
   (*thunk)();
   delete thunk;
   return NULL;
@@ -82,8 +81,8 @@ public:
   {
     cout << "Starting task " << task.task_id().value() << endl;
 
-    std::tr1::function<void(void)>* thunk =
-      new std::tr1::function<void(void)>(std::tr1::bind(&run, driver, task));
+    lambda::function<void(void)>* thunk =
+      new lambda::function<void(void)>(lambda::bind(&run, driver, task));
 
     pthread_t pthread;
     if (pthread_create(&pthread, NULL, &start, thunk) != 0) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/master/detector.cpp
----------------------------------------------------------------------
diff --git a/src/master/detector.cpp b/src/master/detector.cpp
index 7b437ac..532e048 100644
--- a/src/master/detector.cpp
+++ b/src/master/detector.cpp
@@ -19,9 +19,6 @@
 #include <set>
 #include <string>
 
-#include <tr1/functional>
-#include <tr1/memory> // TODO(benh): Replace shared_ptr with unique_ptr.
-
 #include <process/defer.hpp>
 #include <process/dispatch.hpp>
 #include <process/future.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index d7cd89f..5eee60f 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -29,6 +29,7 @@
 
 #include <stout/foreach.hpp>
 #include <stout/json.hpp>
+#include <stout/memory.hpp>
 #include <stout/net.hpp>
 #include <stout/numify.hpp>
 #include <stout/os.hpp>
@@ -447,7 +448,7 @@ Future<Response> Master::Http::state(const Request& request)
   {
     JSON::Array array;
 
-    foreach (const std::tr1::shared_ptr<Framework>& framework,
+    foreach (const memory::shared_ptr<Framework>& framework,
              master.completedFrameworks) {
       array.values.push_back(model(*framework));
     }
@@ -538,7 +539,7 @@ Future<Response> Master::Http::tasks(const Request& request)
   foreachvalue (Framework* framework, master.frameworks) {
     frameworks.push_back(framework);
   }
-  foreach (const std::tr1::shared_ptr<Framework>& framework,
+  foreach (const memory::shared_ptr<Framework>& framework,
            master.completedFrameworks) {
     frameworks.push_back(framework.get());
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 38c5532..fa1277a 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -28,6 +28,7 @@
 
 #include <stout/check.hpp>
 #include <stout/lambda.hpp>
+#include <stout/memory.hpp>
 #include <stout/multihashmap.hpp>
 #include <stout/nothing.hpp>
 #include <stout/os.hpp>
@@ -54,7 +55,7 @@ using std::vector;
 
 using process::wait; // Necessary on some OS's to disambiguate.
 
-using std::tr1::shared_ptr;
+using memory::shared_ptr;
 
 namespace mesos {
 namespace internal {
@@ -2540,7 +2541,7 @@ void Master::removeFramework(Framework* framework)
   framework->unregisteredTime = Clock::now();
 
   // The completedFramework buffer now owns the framework pointer.
-  completedFrameworks.push_back(std::tr1::shared_ptr<Framework>(framework));
+  completedFrameworks.push_back(shared_ptr<Framework>(framework));
 
   CHECK(roles.contains(framework->info.role()))
     << "Unknown role " << framework->info.role()

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 95b9cec..10feb93 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -23,8 +23,6 @@
 #include <string>
 #include <vector>
 
-#include <tr1/functional>
-
 #include <boost/circular_buffer.hpp>
 
 #include <mesos/resources.hpp>
@@ -37,6 +35,7 @@
 #include <stout/foreach.hpp>
 #include <stout/hashmap.hpp>
 #include <stout/hashset.hpp>
+#include <stout/memory.hpp>
 #include <stout/multihashmap.hpp>
 #include <stout/option.hpp>
 
@@ -355,7 +354,7 @@ private:
   // Authenticated frameworks keyed by framework's PID.
   hashset<UPID> authenticated;
 
-  boost::circular_buffer<std::tr1::shared_ptr<Framework> > completedFrameworks;
+  boost::circular_buffer<memory::shared_ptr<Framework> > completedFrameworks;
 
   int64_t nextFrameworkId; // Used to give each framework a unique ID.
   int64_t nextOfferId;     // Used to give each slot offer a unique ID.

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index b00f970..34edef2 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -23,8 +23,6 @@
 #include <string>
 #include <vector>
 
-#include <tr1/functional>
-
 #include <boost/circular_buffer.hpp>
 
 #include <mesos/resources.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/tests/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper.cpp b/src/tests/zookeeper.cpp
index 8bb4901..8462f1f 100644
--- a/src/tests/zookeeper.cpp
+++ b/src/tests/zookeeper.cpp
@@ -22,8 +22,6 @@
 
 #include <queue>
 
-#include <tr1/functional>
-
 #include <jvm/jvm.hpp>
 
 #include <jvm/org/apache/log4j.hpp>
@@ -158,7 +156,7 @@ ZooKeeperTest::TestWatcher::awaitEvent()
 
 ZooKeeperTest::TestWatcher::Event
 ZooKeeperTest::TestWatcher::awaitEvent(
-    const std::tr1::function<bool(Event)>& matches)
+    const lambda::function<bool(Event)>& matches)
 {
   while (true) {
     Event event = awaitEvent();

http://git-wip-us.apache.org/repos/asf/mesos/blob/70aeb47d/src/tests/zookeeper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper.hpp b/src/tests/zookeeper.hpp
index 1bc38c2..48844e2 100644
--- a/src/tests/zookeeper.hpp
+++ b/src/tests/zookeeper.hpp
@@ -25,8 +25,6 @@
 
 #include <queue>
 
-#include <tr1/functional>
-
 #include <stout/duration.hpp>
 
 #include "tests/zookeeper_test_server.hpp"
@@ -104,7 +102,7 @@ public:
     void awaitCreated(const std::string& path);
 
     // Blocks until an event is fired matching the given predicate.
-    Event awaitEvent(const std::tr1::function<bool(Event)>& matches);
+    Event awaitEvent(const lambda::function<bool(Event)>& matches);
 
     // Blocks until an event is fired.
     Event awaitEvent();


[02/15] git commit: Upgraded stout to protobuf 2.5.0.

Posted by be...@apache.org.
Upgraded stout to protobuf 2.5.0.

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


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

Branch: refs/heads/master
Commit: 2cf878513fb5fdb1fe0e34df51c42916da5c29e6
Parents: bdc372d
Author: Benjamin Hindman <be...@gmail.com>
Authored: Mon Dec 30 11:15:02 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Jan 13 23:38:54 2014 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/tests/protobuf_tests.pb.cc   | 242 ++++++++++---------
 .../3rdparty/stout/tests/protobuf_tests.pb.h    | 215 +++++++++-------
 2 files changed, 257 insertions(+), 200 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2cf87851/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
index ecf34e1..ca01feb 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
@@ -1,14 +1,17 @@
 // Generated by the protocol buffer compiler.  DO NOT EDIT!
+// source: protobuf_tests.proto
 
 #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
 #include "protobuf_tests.pb.h"
 
 #include <algorithm>
 
+#include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/once.h>
 #include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/wire_format_lite_inl.h>
 #include <google/protobuf/descriptor.h>
+#include <google/protobuf/generated_message_reflection.h>
 #include <google/protobuf/reflection_ops.h>
 #include <google/protobuf/wire_format.h>
 // @@protoc_insertion_point(includes)
@@ -154,7 +157,6 @@ struct StaticDescriptorInitializer_protobuf_5ftests_2eproto {
     protobuf_AddDesc_protobuf_5ftests_2eproto();
   }
 } static_descriptor_initializer_protobuf_5ftests_2eproto_;
-
 const ::google::protobuf::EnumDescriptor* Enum_descriptor() {
   protobuf_AssignDescriptorsOnce();
   return Enum_descriptor_;
@@ -219,7 +221,8 @@ const ::google::protobuf::Descriptor* Nested::descriptor() {
 }
 
 const Nested& Nested::default_instance() {
-  if (default_instance_ == NULL) protobuf_AddDesc_protobuf_5ftests_2eproto();  return *default_instance_;
+  if (default_instance_ == NULL) protobuf_AddDesc_protobuf_5ftests_2eproto();
+  return *default_instance_;
 }
 
 Nested* Nested::default_instance_ = NULL;
@@ -261,7 +264,7 @@ bool Nested::MergePartialFromCodedStream(
         if (input->ExpectAtEnd()) return true;
         break;
       }
-      
+
       default: {
       handle_uninterpreted:
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -288,7 +291,7 @@ void Nested::SerializeWithCachedSizes(
     ::google::protobuf::internal::WireFormatLite::WriteString(
       1, this->str(), output);
   }
-  
+
   if (!unknown_fields().empty()) {
     ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
         unknown_fields(), output);
@@ -306,7 +309,7 @@ void Nested::SerializeWithCachedSizes(
       ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
         1, this->str(), target);
   }
-  
+
   if (!unknown_fields().empty()) {
     target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
         unknown_fields(), target);
@@ -316,7 +319,7 @@ void Nested::SerializeWithCachedSizes(
 
 int Nested::ByteSize() const {
   int total_size = 0;
-  
+
   if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
     // optional string str = 1;
     if (has_str()) {
@@ -324,7 +327,7 @@ int Nested::ByteSize() const {
         ::google::protobuf::internal::WireFormatLite::StringSize(
           this->str());
     }
-    
+
   }
   if (!unknown_fields().empty()) {
     total_size +=
@@ -372,7 +375,7 @@ void Nested::CopyFrom(const Nested& from) {
 }
 
 bool Nested::IsInitialized() const {
-  
+
   return true;
 }
 
@@ -483,7 +486,8 @@ const ::google::protobuf::Descriptor* Message::descriptor() {
 }
 
 const Message& Message::default_instance() {
-  if (default_instance_ == NULL) protobuf_AddDesc_protobuf_5ftests_2eproto();  return *default_instance_;
+  if (default_instance_ == NULL) protobuf_AddDesc_protobuf_5ftests_2eproto();
+  return *default_instance_;
 }
 
 Message* Message::default_instance_ = NULL;
@@ -557,7 +561,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(18)) goto parse_bytes;
         break;
       }
-      
+
       // required bytes bytes = 2;
       case 2: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -571,7 +575,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(24)) goto parse_int32;
         break;
       }
-      
+
       // optional int32 int32 = 3;
       case 3: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -587,7 +591,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(32)) goto parse_int64;
         break;
       }
-      
+
       // optional int64 int64 = 4;
       case 4: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -603,7 +607,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(40)) goto parse_uint32;
         break;
       }
-      
+
       // optional uint32 uint32 = 5;
       case 5: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -619,7 +623,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(48)) goto parse_uint64;
         break;
       }
-      
+
       // optional uint64 uint64 = 6;
       case 6: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -635,7 +639,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(56)) goto parse_sint32;
         break;
       }
-      
+
       // optional sint32 sint32 = 7;
       case 7: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -651,7 +655,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(64)) goto parse_sint64;
         break;
       }
-      
+
       // optional sint64 sint64 = 8;
       case 8: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -667,7 +671,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(77)) goto parse_f;
         break;
       }
-      
+
       // required float f = 9;
       case 9: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -683,7 +687,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(81)) goto parse_d;
         break;
       }
-      
+
       // required double d = 10;
       case 10: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -699,7 +703,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(88)) goto parse_e;
         break;
       }
-      
+
       // required .tests.Enum e = 11;
       case 11: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -709,8 +713,8 @@ bool Message::MergePartialFromCodedStream(
           DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                    int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
                  input, &value)));
-          if (tests::Enum_IsValid(value)) {
-            set_e(static_cast< tests::Enum >(value));
+          if (::tests::Enum_IsValid(value)) {
+            set_e(static_cast< ::tests::Enum >(value));
           } else {
             mutable_unknown_fields()->AddVarint(11, value);
           }
@@ -720,7 +724,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(98)) goto parse_nested;
         break;
       }
-      
+
       // required .tests.Nested nested = 12;
       case 12: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -734,7 +738,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(106)) goto parse_repeated_string;
         break;
       }
-      
+
       // repeated string repeated_string = 13;
       case 13: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -743,7 +747,8 @@ bool Message::MergePartialFromCodedStream(
           DO_(::google::protobuf::internal::WireFormatLite::ReadString(
                 input, this->add_repeated_string()));
           ::google::protobuf::internal::WireFormat::VerifyUTF8String(
-            this->repeated_string(0).data(), this->repeated_string(0).length(),
+            this->repeated_string(this->repeated_string_size() - 1).data(),
+            this->repeated_string(this->repeated_string_size() - 1).length(),
             ::google::protobuf::internal::WireFormat::PARSE);
         } else {
           goto handle_uninterpreted;
@@ -752,7 +757,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(114)) goto parse_repeated_bytes;
         break;
       }
-      
+
       // repeated bytes repeated_bytes = 14;
       case 14: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -767,7 +772,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(120)) goto parse_repeated_int32;
         break;
       }
-      
+
       // repeated int32 repeated_int32 = 15;
       case 15: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -789,7 +794,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(128)) goto parse_repeated_int64;
         break;
       }
-      
+
       // repeated int64 repeated_int64 = 16;
       case 16: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -811,7 +816,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(136)) goto parse_repeated_uint32;
         break;
       }
-      
+
       // repeated uint32 repeated_uint32 = 17;
       case 17: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -833,7 +838,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(144)) goto parse_repeated_uint64;
         break;
       }
-      
+
       // repeated uint64 repeated_uint64 = 18;
       case 18: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -855,7 +860,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(152)) goto parse_repeated_sint32;
         break;
       }
-      
+
       // repeated sint32 repeated_sint32 = 19;
       case 19: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -877,7 +882,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(160)) goto parse_repeated_sint64;
         break;
       }
-      
+
       // repeated sint64 repeated_sint64 = 20;
       case 20: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -899,7 +904,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(173)) goto parse_repeated_float;
         break;
       }
-      
+
       // repeated float repeated_float = 21;
       case 21: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -921,7 +926,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(177)) goto parse_repeated_double;
         break;
       }
-      
+
       // repeated double repeated_double = 22;
       case 22: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -943,7 +948,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(184)) goto parse_repeated_enum;
         break;
       }
-      
+
       // repeated .tests.Enum repeated_enum = 23;
       case 23: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -953,8 +958,8 @@ bool Message::MergePartialFromCodedStream(
           DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                    int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
                  input, &value)));
-          if (tests::Enum_IsValid(value)) {
-            add_repeated_enum(static_cast< tests::Enum >(value));
+          if (::tests::Enum_IsValid(value)) {
+            add_repeated_enum(static_cast< ::tests::Enum >(value));
           } else {
             mutable_unknown_fields()->AddVarint(23, value);
           }
@@ -963,7 +968,7 @@ bool Message::MergePartialFromCodedStream(
                       WIRETYPE_LENGTH_DELIMITED) {
           DO_((::google::protobuf::internal::WireFormatLite::ReadPackedEnumNoInline(
                  input,
-                 &tests::Enum_IsValid,
+                 &::tests::Enum_IsValid,
                  this->mutable_repeated_enum())));
         } else {
           goto handle_uninterpreted;
@@ -972,7 +977,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(194)) goto parse_repeated_nested;
         break;
       }
-      
+
       // repeated .tests.Nested repeated_nested = 24;
       case 24: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -987,7 +992,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectTag(202)) goto parse_empty;
         break;
       }
-      
+
       // repeated string empty = 25;
       case 25: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -996,7 +1001,8 @@ bool Message::MergePartialFromCodedStream(
           DO_(::google::protobuf::internal::WireFormatLite::ReadString(
                 input, this->add_empty()));
           ::google::protobuf::internal::WireFormat::VerifyUTF8String(
-            this->empty(0).data(), this->empty(0).length(),
+            this->empty(this->empty_size() - 1).data(),
+            this->empty(this->empty_size() - 1).length(),
             ::google::protobuf::internal::WireFormat::PARSE);
         } else {
           goto handle_uninterpreted;
@@ -1005,7 +1011,7 @@ bool Message::MergePartialFromCodedStream(
         if (input->ExpectAtEnd()) return true;
         break;
       }
-      
+
       default: {
       handle_uninterpreted:
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
@@ -1032,65 +1038,65 @@ void Message::SerializeWithCachedSizes(
     ::google::protobuf::internal::WireFormatLite::WriteString(
       1, this->str(), output);
   }
-  
+
   // required bytes bytes = 2;
   if (has_bytes()) {
     ::google::protobuf::internal::WireFormatLite::WriteBytes(
       2, this->bytes(), output);
   }
-  
+
   // optional int32 int32 = 3;
   if (has_int32()) {
     ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->int32(), output);
   }
-  
+
   // optional int64 int64 = 4;
   if (has_int64()) {
     ::google::protobuf::internal::WireFormatLite::WriteInt64(4, this->int64(), output);
   }
-  
+
   // optional uint32 uint32 = 5;
   if (has_uint32()) {
     ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->uint32(), output);
   }
-  
+
   // optional uint64 uint64 = 6;
   if (has_uint64()) {
     ::google::protobuf::internal::WireFormatLite::WriteUInt64(6, this->uint64(), output);
   }
-  
+
   // optional sint32 sint32 = 7;
   if (has_sint32()) {
     ::google::protobuf::internal::WireFormatLite::WriteSInt32(7, this->sint32(), output);
   }
-  
+
   // optional sint64 sint64 = 8;
   if (has_sint64()) {
     ::google::protobuf::internal::WireFormatLite::WriteSInt64(8, this->sint64(), output);
   }
-  
+
   // required float f = 9;
   if (has_f()) {
     ::google::protobuf::internal::WireFormatLite::WriteFloat(9, this->f(), output);
   }
-  
+
   // required double d = 10;
   if (has_d()) {
     ::google::protobuf::internal::WireFormatLite::WriteDouble(10, this->d(), output);
   }
-  
+
   // required .tests.Enum e = 11;
   if (has_e()) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       11, this->e(), output);
   }
-  
+
   // required .tests.Nested nested = 12;
   if (has_nested()) {
     ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
       12, this->nested(), output);
   }
-  
+
   // repeated string repeated_string = 13;
   for (int i = 0; i < this->repeated_string_size(); i++) {
   ::google::protobuf::internal::WireFormat::VerifyUTF8String(
@@ -1099,73 +1105,73 @@ void Message::SerializeWithCachedSizes(
     ::google::protobuf::internal::WireFormatLite::WriteString(
       13, this->repeated_string(i), output);
   }
-  
+
   // repeated bytes repeated_bytes = 14;
   for (int i = 0; i < this->repeated_bytes_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteBytes(
       14, this->repeated_bytes(i), output);
   }
-  
+
   // repeated int32 repeated_int32 = 15;
   for (int i = 0; i < this->repeated_int32_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteInt32(
       15, this->repeated_int32(i), output);
   }
-  
+
   // repeated int64 repeated_int64 = 16;
   for (int i = 0; i < this->repeated_int64_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteInt64(
       16, this->repeated_int64(i), output);
   }
-  
+
   // repeated uint32 repeated_uint32 = 17;
   for (int i = 0; i < this->repeated_uint32_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteUInt32(
       17, this->repeated_uint32(i), output);
   }
-  
+
   // repeated uint64 repeated_uint64 = 18;
   for (int i = 0; i < this->repeated_uint64_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteUInt64(
       18, this->repeated_uint64(i), output);
   }
-  
+
   // repeated sint32 repeated_sint32 = 19;
   for (int i = 0; i < this->repeated_sint32_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteSInt32(
       19, this->repeated_sint32(i), output);
   }
-  
+
   // repeated sint64 repeated_sint64 = 20;
   for (int i = 0; i < this->repeated_sint64_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteSInt64(
       20, this->repeated_sint64(i), output);
   }
-  
+
   // repeated float repeated_float = 21;
   for (int i = 0; i < this->repeated_float_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteFloat(
       21, this->repeated_float(i), output);
   }
-  
+
   // repeated double repeated_double = 22;
   for (int i = 0; i < this->repeated_double_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteDouble(
       22, this->repeated_double(i), output);
   }
-  
+
   // repeated .tests.Enum repeated_enum = 23;
   for (int i = 0; i < this->repeated_enum_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       23, this->repeated_enum(i), output);
   }
-  
+
   // repeated .tests.Nested repeated_nested = 24;
   for (int i = 0; i < this->repeated_nested_size(); i++) {
     ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
       24, this->repeated_nested(i), output);
   }
-  
+
   // repeated string empty = 25;
   for (int i = 0; i < this->empty_size(); i++) {
   ::google::protobuf::internal::WireFormat::VerifyUTF8String(
@@ -1174,7 +1180,7 @@ void Message::SerializeWithCachedSizes(
     ::google::protobuf::internal::WireFormatLite::WriteString(
       25, this->empty(i), output);
   }
-  
+
   if (!unknown_fields().empty()) {
     ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
         unknown_fields(), output);
@@ -1192,67 +1198,67 @@ void Message::SerializeWithCachedSizes(
       ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
         1, this->str(), target);
   }
-  
+
   // required bytes bytes = 2;
   if (has_bytes()) {
     target =
       ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
         2, this->bytes(), target);
   }
-  
+
   // optional int32 int32 = 3;
   if (has_int32()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->int32(), target);
   }
-  
+
   // optional int64 int64 = 4;
   if (has_int64()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(4, this->int64(), target);
   }
-  
+
   // optional uint32 uint32 = 5;
   if (has_uint32()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->uint32(), target);
   }
-  
+
   // optional uint64 uint64 = 6;
   if (has_uint64()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(6, this->uint64(), target);
   }
-  
+
   // optional sint32 sint32 = 7;
   if (has_sint32()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteSInt32ToArray(7, this->sint32(), target);
   }
-  
+
   // optional sint64 sint64 = 8;
   if (has_sint64()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteSInt64ToArray(8, this->sint64(), target);
   }
-  
+
   // required float f = 9;
   if (has_f()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(9, this->f(), target);
   }
-  
+
   // required double d = 10;
   if (has_d()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(10, this->d(), target);
   }
-  
+
   // required .tests.Enum e = 11;
   if (has_e()) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       11, this->e(), target);
   }
-  
+
   // required .tests.Nested nested = 12;
   if (has_nested()) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteMessageNoVirtualToArray(
         12, this->nested(), target);
   }
-  
+
   // repeated string repeated_string = 13;
   for (int i = 0; i < this->repeated_string_size(); i++) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8String(
@@ -1261,74 +1267,74 @@ void Message::SerializeWithCachedSizes(
     target = ::google::protobuf::internal::WireFormatLite::
       WriteStringToArray(13, this->repeated_string(i), target);
   }
-  
+
   // repeated bytes repeated_bytes = 14;
   for (int i = 0; i < this->repeated_bytes_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteBytesToArray(14, this->repeated_bytes(i), target);
   }
-  
+
   // repeated int32 repeated_int32 = 15;
   for (int i = 0; i < this->repeated_int32_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteInt32ToArray(15, this->repeated_int32(i), target);
   }
-  
+
   // repeated int64 repeated_int64 = 16;
   for (int i = 0; i < this->repeated_int64_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteInt64ToArray(16, this->repeated_int64(i), target);
   }
-  
+
   // repeated uint32 repeated_uint32 = 17;
   for (int i = 0; i < this->repeated_uint32_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteUInt32ToArray(17, this->repeated_uint32(i), target);
   }
-  
+
   // repeated uint64 repeated_uint64 = 18;
   for (int i = 0; i < this->repeated_uint64_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteUInt64ToArray(18, this->repeated_uint64(i), target);
   }
-  
+
   // repeated sint32 repeated_sint32 = 19;
   for (int i = 0; i < this->repeated_sint32_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteSInt32ToArray(19, this->repeated_sint32(i), target);
   }
-  
+
   // repeated sint64 repeated_sint64 = 20;
   for (int i = 0; i < this->repeated_sint64_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteSInt64ToArray(20, this->repeated_sint64(i), target);
   }
-  
+
   // repeated float repeated_float = 21;
   for (int i = 0; i < this->repeated_float_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteFloatToArray(21, this->repeated_float(i), target);
   }
-  
+
   // repeated double repeated_double = 22;
   for (int i = 0; i < this->repeated_double_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteDoubleToArray(22, this->repeated_double(i), target);
   }
-  
+
   // repeated .tests.Enum repeated_enum = 23;
   for (int i = 0; i < this->repeated_enum_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       23, this->repeated_enum(i), target);
   }
-  
+
   // repeated .tests.Nested repeated_nested = 24;
   for (int i = 0; i < this->repeated_nested_size(); i++) {
     target = ::google::protobuf::internal::WireFormatLite::
       WriteMessageNoVirtualToArray(
         24, this->repeated_nested(i), target);
   }
-  
+
   // repeated string empty = 25;
   for (int i = 0; i < this->empty_size(); i++) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8String(
@@ -1337,7 +1343,7 @@ void Message::SerializeWithCachedSizes(
     target = ::google::protobuf::internal::WireFormatLite::
       WriteStringToArray(25, this->empty(i), target);
   }
-  
+
   if (!unknown_fields().empty()) {
     target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
         unknown_fields(), target);
@@ -1347,7 +1353,7 @@ void Message::SerializeWithCachedSizes(
 
 int Message::ByteSize() const {
   int total_size = 0;
-  
+
   if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
     // required string str = 1;
     if (has_str()) {
@@ -1355,81 +1361,81 @@ int Message::ByteSize() const {
         ::google::protobuf::internal::WireFormatLite::StringSize(
           this->str());
     }
-    
+
     // required bytes bytes = 2;
     if (has_bytes()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::BytesSize(
           this->bytes());
     }
-    
+
     // optional int32 int32 = 3;
     if (has_int32()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::Int32Size(
           this->int32());
     }
-    
+
     // optional int64 int64 = 4;
     if (has_int64()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::Int64Size(
           this->int64());
     }
-    
+
     // optional uint32 uint32 = 5;
     if (has_uint32()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::UInt32Size(
           this->uint32());
     }
-    
+
     // optional uint64 uint64 = 6;
     if (has_uint64()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::UInt64Size(
           this->uint64());
     }
-    
+
     // optional sint32 sint32 = 7;
     if (has_sint32()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::SInt32Size(
           this->sint32());
     }
-    
+
     // optional sint64 sint64 = 8;
     if (has_sint64()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::SInt64Size(
           this->sint64());
     }
-    
+
   }
   if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) {
     // required float f = 9;
     if (has_f()) {
       total_size += 1 + 4;
     }
-    
+
     // required double d = 10;
     if (has_d()) {
       total_size += 1 + 8;
     }
-    
+
     // required .tests.Enum e = 11;
     if (has_e()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::EnumSize(this->e());
     }
-    
+
     // required .tests.Nested nested = 12;
     if (has_nested()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
           this->nested());
     }
-    
+
   }
   // repeated string repeated_string = 13;
   total_size += 1 * this->repeated_string_size();
@@ -1437,14 +1443,14 @@ int Message::ByteSize() const {
     total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
       this->repeated_string(i));
   }
-  
+
   // repeated bytes repeated_bytes = 14;
   total_size += 1 * this->repeated_bytes_size();
   for (int i = 0; i < this->repeated_bytes_size(); i++) {
     total_size += ::google::protobuf::internal::WireFormatLite::BytesSize(
       this->repeated_bytes(i));
   }
-  
+
   // repeated int32 repeated_int32 = 15;
   {
     int data_size = 0;
@@ -1454,7 +1460,7 @@ int Message::ByteSize() const {
     }
     total_size += 1 * this->repeated_int32_size() + data_size;
   }
-  
+
   // repeated int64 repeated_int64 = 16;
   {
     int data_size = 0;
@@ -1464,7 +1470,7 @@ int Message::ByteSize() const {
     }
     total_size += 2 * this->repeated_int64_size() + data_size;
   }
-  
+
   // repeated uint32 repeated_uint32 = 17;
   {
     int data_size = 0;
@@ -1474,7 +1480,7 @@ int Message::ByteSize() const {
     }
     total_size += 2 * this->repeated_uint32_size() + data_size;
   }
-  
+
   // repeated uint64 repeated_uint64 = 18;
   {
     int data_size = 0;
@@ -1484,7 +1490,7 @@ int Message::ByteSize() const {
     }
     total_size += 2 * this->repeated_uint64_size() + data_size;
   }
-  
+
   // repeated sint32 repeated_sint32 = 19;
   {
     int data_size = 0;
@@ -1494,7 +1500,7 @@ int Message::ByteSize() const {
     }
     total_size += 2 * this->repeated_sint32_size() + data_size;
   }
-  
+
   // repeated sint64 repeated_sint64 = 20;
   {
     int data_size = 0;
@@ -1504,21 +1510,21 @@ int Message::ByteSize() const {
     }
     total_size += 2 * this->repeated_sint64_size() + data_size;
   }
-  
+
   // repeated float repeated_float = 21;
   {
     int data_size = 0;
     data_size = 4 * this->repeated_float_size();
     total_size += 2 * this->repeated_float_size() + data_size;
   }
-  
+
   // repeated double repeated_double = 22;
   {
     int data_size = 0;
     data_size = 8 * this->repeated_double_size();
     total_size += 2 * this->repeated_double_size() + data_size;
   }
-  
+
   // repeated .tests.Enum repeated_enum = 23;
   {
     int data_size = 0;
@@ -1528,7 +1534,7 @@ int Message::ByteSize() const {
     }
     total_size += 2 * this->repeated_enum_size() + data_size;
   }
-  
+
   // repeated .tests.Nested repeated_nested = 24;
   total_size += 2 * this->repeated_nested_size();
   for (int i = 0; i < this->repeated_nested_size(); i++) {
@@ -1536,14 +1542,14 @@ int Message::ByteSize() const {
       ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
         this->repeated_nested(i));
   }
-  
+
   // repeated string empty = 25;
   total_size += 2 * this->empty_size();
   for (int i = 0; i < this->empty_size(); i++) {
     total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
       this->empty(i));
   }
-  
+
   if (!unknown_fields().empty()) {
     total_size +=
       ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
@@ -1639,7 +1645,7 @@ void Message::CopyFrom(const Message& from) {
 
 bool Message::IsInitialized() const {
   if ((_has_bits_[0] & 0x00000f03) != 0x00000f03) return false;
-  
+
   return true;
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/2cf87851/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
index aef5b29..c155133 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
@@ -8,21 +8,23 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 2004000
+#if GOOGLE_PROTOBUF_VERSION < 2005000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 2004001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.
 #endif
 
 #include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/message.h>
 #include <google/protobuf/repeated_field.h>
 #include <google/protobuf/extension_set.h>
-#include <google/protobuf/generated_message_reflection.h>
+#include <google/protobuf/generated_enum_reflection.h>
+#include <google/protobuf/unknown_field_set.h>
 // @@protoc_insertion_point(includes)
 
 namespace tests {
@@ -60,29 +62,29 @@ class Nested : public ::google::protobuf::Message {
  public:
   Nested();
   virtual ~Nested();
-  
+
   Nested(const Nested& from);
-  
+
   inline Nested& operator=(const Nested& from) {
     CopyFrom(from);
     return *this;
   }
-  
+
   inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
     return _unknown_fields_;
   }
-  
+
   inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
     return &_unknown_fields_;
   }
-  
+
   static const ::google::protobuf::Descriptor* descriptor();
   static const Nested& default_instance();
-  
+
   void Swap(Nested* other);
-  
+
   // implements Message ----------------------------------------------
-  
+
   Nested* New() const;
   void CopyFrom(const ::google::protobuf::Message& from);
   void MergeFrom(const ::google::protobuf::Message& from);
@@ -90,7 +92,7 @@ class Nested : public ::google::protobuf::Message {
   void MergeFrom(const Nested& from);
   void Clear();
   bool IsInitialized() const;
-  
+
   int ByteSize() const;
   bool MergePartialFromCodedStream(
       ::google::protobuf::io::CodedInputStream* input);
@@ -103,13 +105,13 @@ class Nested : public ::google::protobuf::Message {
   void SharedDtor();
   void SetCachedSize(int size) const;
   public:
-  
+
   ::google::protobuf::Metadata GetMetadata() const;
-  
+
   // nested types ----------------------------------------------------
-  
+
   // accessors -------------------------------------------------------
-  
+
   // optional string str = 1;
   inline bool has_str() const;
   inline void clear_str();
@@ -120,23 +122,24 @@ class Nested : public ::google::protobuf::Message {
   inline void set_str(const char* value, size_t size);
   inline ::std::string* mutable_str();
   inline ::std::string* release_str();
-  
+  inline void set_allocated_str(::std::string* str);
+
   // @@protoc_insertion_point(class_scope:tests.Nested)
  private:
   inline void set_has_str();
   inline void clear_has_str();
-  
+
   ::google::protobuf::UnknownFieldSet _unknown_fields_;
-  
+
   ::std::string* str_;
-  
+
   mutable int _cached_size_;
   ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
-  
+
   friend void  protobuf_AddDesc_protobuf_5ftests_2eproto();
   friend void protobuf_AssignDesc_protobuf_5ftests_2eproto();
   friend void protobuf_ShutdownFile_protobuf_5ftests_2eproto();
-  
+
   void InitAsDefaultInstance();
   static Nested* default_instance_;
 };
@@ -146,29 +149,29 @@ class Message : public ::google::protobuf::Message {
  public:
   Message();
   virtual ~Message();
-  
+
   Message(const Message& from);
-  
+
   inline Message& operator=(const Message& from) {
     CopyFrom(from);
     return *this;
   }
-  
+
   inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
     return _unknown_fields_;
   }
-  
+
   inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
     return &_unknown_fields_;
   }
-  
+
   static const ::google::protobuf::Descriptor* descriptor();
   static const Message& default_instance();
-  
+
   void Swap(Message* other);
-  
+
   // implements Message ----------------------------------------------
-  
+
   Message* New() const;
   void CopyFrom(const ::google::protobuf::Message& from);
   void MergeFrom(const ::google::protobuf::Message& from);
@@ -176,7 +179,7 @@ class Message : public ::google::protobuf::Message {
   void MergeFrom(const Message& from);
   void Clear();
   bool IsInitialized() const;
-  
+
   int ByteSize() const;
   bool MergePartialFromCodedStream(
       ::google::protobuf::io::CodedInputStream* input);
@@ -189,13 +192,13 @@ class Message : public ::google::protobuf::Message {
   void SharedDtor();
   void SetCachedSize(int size) const;
   public:
-  
+
   ::google::protobuf::Metadata GetMetadata() const;
-  
+
   // nested types ----------------------------------------------------
-  
+
   // accessors -------------------------------------------------------
-  
+
   // required string str = 1;
   inline bool has_str() const;
   inline void clear_str();
@@ -206,7 +209,8 @@ class Message : public ::google::protobuf::Message {
   inline void set_str(const char* value, size_t size);
   inline ::std::string* mutable_str();
   inline ::std::string* release_str();
-  
+  inline void set_allocated_str(::std::string* str);
+
   // required bytes bytes = 2;
   inline bool has_bytes() const;
   inline void clear_bytes();
@@ -217,70 +221,71 @@ class Message : public ::google::protobuf::Message {
   inline void set_bytes(const void* value, size_t size);
   inline ::std::string* mutable_bytes();
   inline ::std::string* release_bytes();
-  
+  inline void set_allocated_bytes(::std::string* bytes);
+
   // optional int32 int32 = 3;
   inline bool has_int32() const;
   inline void clear_int32();
   static const int kInt32FieldNumber = 3;
   inline ::google::protobuf::int32 int32() const;
   inline void set_int32(::google::protobuf::int32 value);
-  
+
   // optional int64 int64 = 4;
   inline bool has_int64() const;
   inline void clear_int64();
   static const int kInt64FieldNumber = 4;
   inline ::google::protobuf::int64 int64() const;
   inline void set_int64(::google::protobuf::int64 value);
-  
+
   // optional uint32 uint32 = 5;
   inline bool has_uint32() const;
   inline void clear_uint32();
   static const int kUint32FieldNumber = 5;
   inline ::google::protobuf::uint32 uint32() const;
   inline void set_uint32(::google::protobuf::uint32 value);
-  
+
   // optional uint64 uint64 = 6;
   inline bool has_uint64() const;
   inline void clear_uint64();
   static const int kUint64FieldNumber = 6;
   inline ::google::protobuf::uint64 uint64() const;
   inline void set_uint64(::google::protobuf::uint64 value);
-  
+
   // optional sint32 sint32 = 7;
   inline bool has_sint32() const;
   inline void clear_sint32();
   static const int kSint32FieldNumber = 7;
   inline ::google::protobuf::int32 sint32() const;
   inline void set_sint32(::google::protobuf::int32 value);
-  
+
   // optional sint64 sint64 = 8;
   inline bool has_sint64() const;
   inline void clear_sint64();
   static const int kSint64FieldNumber = 8;
   inline ::google::protobuf::int64 sint64() const;
   inline void set_sint64(::google::protobuf::int64 value);
-  
+
   // required float f = 9;
   inline bool has_f() const;
   inline void clear_f();
   static const int kFFieldNumber = 9;
   inline float f() const;
   inline void set_f(float value);
-  
+
   // required double d = 10;
   inline bool has_d() const;
   inline void clear_d();
   static const int kDFieldNumber = 10;
   inline double d() const;
   inline void set_d(double value);
-  
+
   // required .tests.Enum e = 11;
   inline bool has_e() const;
   inline void clear_e();
   static const int kEFieldNumber = 11;
-  inline tests::Enum e() const;
-  inline void set_e(tests::Enum value);
-  
+  inline ::tests::Enum e() const;
+  inline void set_e(::tests::Enum value);
+
   // required .tests.Nested nested = 12;
   inline bool has_nested() const;
   inline void clear_nested();
@@ -288,7 +293,8 @@ class Message : public ::google::protobuf::Message {
   inline const ::tests::Nested& nested() const;
   inline ::tests::Nested* mutable_nested();
   inline ::tests::Nested* release_nested();
-  
+  inline void set_allocated_nested(::tests::Nested* nested);
+
   // repeated string repeated_string = 13;
   inline int repeated_string_size() const;
   inline void clear_repeated_string();
@@ -304,7 +310,7 @@ class Message : public ::google::protobuf::Message {
   inline void add_repeated_string(const char* value, size_t size);
   inline const ::google::protobuf::RepeatedPtrField< ::std::string>& repeated_string() const;
   inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_repeated_string();
-  
+
   // repeated bytes repeated_bytes = 14;
   inline int repeated_bytes_size() const;
   inline void clear_repeated_bytes();
@@ -320,7 +326,7 @@ class Message : public ::google::protobuf::Message {
   inline void add_repeated_bytes(const void* value, size_t size);
   inline const ::google::protobuf::RepeatedPtrField< ::std::string>& repeated_bytes() const;
   inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_repeated_bytes();
-  
+
   // repeated int32 repeated_int32 = 15;
   inline int repeated_int32_size() const;
   inline void clear_repeated_int32();
@@ -332,7 +338,7 @@ class Message : public ::google::protobuf::Message {
       repeated_int32() const;
   inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
       mutable_repeated_int32();
-  
+
   // repeated int64 repeated_int64 = 16;
   inline int repeated_int64_size() const;
   inline void clear_repeated_int64();
@@ -344,7 +350,7 @@ class Message : public ::google::protobuf::Message {
       repeated_int64() const;
   inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
       mutable_repeated_int64();
-  
+
   // repeated uint32 repeated_uint32 = 17;
   inline int repeated_uint32_size() const;
   inline void clear_repeated_uint32();
@@ -356,7 +362,7 @@ class Message : public ::google::protobuf::Message {
       repeated_uint32() const;
   inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
       mutable_repeated_uint32();
-  
+
   // repeated uint64 repeated_uint64 = 18;
   inline int repeated_uint64_size() const;
   inline void clear_repeated_uint64();
@@ -368,7 +374,7 @@ class Message : public ::google::protobuf::Message {
       repeated_uint64() const;
   inline ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >*
       mutable_repeated_uint64();
-  
+
   // repeated sint32 repeated_sint32 = 19;
   inline int repeated_sint32_size() const;
   inline void clear_repeated_sint32();
@@ -380,7 +386,7 @@ class Message : public ::google::protobuf::Message {
       repeated_sint32() const;
   inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
       mutable_repeated_sint32();
-  
+
   // repeated sint64 repeated_sint64 = 20;
   inline int repeated_sint64_size() const;
   inline void clear_repeated_sint64();
@@ -392,7 +398,7 @@ class Message : public ::google::protobuf::Message {
       repeated_sint64() const;
   inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
       mutable_repeated_sint64();
-  
+
   // repeated float repeated_float = 21;
   inline int repeated_float_size() const;
   inline void clear_repeated_float();
@@ -404,7 +410,7 @@ class Message : public ::google::protobuf::Message {
       repeated_float() const;
   inline ::google::protobuf::RepeatedField< float >*
       mutable_repeated_float();
-  
+
   // repeated double repeated_double = 22;
   inline int repeated_double_size() const;
   inline void clear_repeated_double();
@@ -416,17 +422,17 @@ class Message : public ::google::protobuf::Message {
       repeated_double() const;
   inline ::google::protobuf::RepeatedField< double >*
       mutable_repeated_double();
-  
+
   // repeated .tests.Enum repeated_enum = 23;
   inline int repeated_enum_size() const;
   inline void clear_repeated_enum();
   static const int kRepeatedEnumFieldNumber = 23;
-  inline tests::Enum repeated_enum(int index) const;
-  inline void set_repeated_enum(int index, tests::Enum value);
-  inline void add_repeated_enum(tests::Enum value);
+  inline ::tests::Enum repeated_enum(int index) const;
+  inline void set_repeated_enum(int index, ::tests::Enum value);
+  inline void add_repeated_enum(::tests::Enum value);
   inline const ::google::protobuf::RepeatedField<int>& repeated_enum() const;
   inline ::google::protobuf::RepeatedField<int>* mutable_repeated_enum();
-  
+
   // repeated .tests.Nested repeated_nested = 24;
   inline int repeated_nested_size() const;
   inline void clear_repeated_nested();
@@ -438,7 +444,7 @@ class Message : public ::google::protobuf::Message {
       repeated_nested() const;
   inline ::google::protobuf::RepeatedPtrField< ::tests::Nested >*
       mutable_repeated_nested();
-  
+
   // repeated string empty = 25;
   inline int empty_size() const;
   inline void clear_empty();
@@ -454,7 +460,7 @@ class Message : public ::google::protobuf::Message {
   inline void add_empty(const char* value, size_t size);
   inline const ::google::protobuf::RepeatedPtrField< ::std::string>& empty() const;
   inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_empty();
-  
+
   // @@protoc_insertion_point(class_scope:tests.Message)
  private:
   inline void set_has_str();
@@ -481,9 +487,9 @@ class Message : public ::google::protobuf::Message {
   inline void clear_has_e();
   inline void set_has_nested();
   inline void clear_has_nested();
-  
+
   ::google::protobuf::UnknownFieldSet _unknown_fields_;
-  
+
   ::std::string* str_;
   ::std::string* bytes_;
   ::google::protobuf::int64 int64_;
@@ -509,14 +515,14 @@ class Message : public ::google::protobuf::Message {
   ::google::protobuf::RepeatedPtrField< ::tests::Nested > repeated_nested_;
   ::google::protobuf::RepeatedPtrField< ::std::string> empty_;
   int e_;
-  
+
   mutable int _cached_size_;
   ::google::protobuf::uint32 _has_bits_[(25 + 31) / 32];
-  
+
   friend void  protobuf_AddDesc_protobuf_5ftests_2eproto();
   friend void protobuf_AssignDesc_protobuf_5ftests_2eproto();
   friend void protobuf_ShutdownFile_protobuf_5ftests_2eproto();
-  
+
   void InitAsDefaultInstance();
   static Message* default_instance_;
 };
@@ -584,6 +590,18 @@ inline ::std::string* Nested::release_str() {
     return temp;
   }
 }
+inline void Nested::set_allocated_str(::std::string* str) {
+  if (str_ != &::google::protobuf::internal::kEmptyString) {
+    delete str_;
+  }
+  if (str) {
+    set_has_str();
+    str_ = str;
+  } else {
+    clear_has_str();
+    str_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+  }
+}
 
 // -------------------------------------------------------------------
 
@@ -646,6 +664,18 @@ inline ::std::string* Message::release_str() {
     return temp;
   }
 }
+inline void Message::set_allocated_str(::std::string* str) {
+  if (str_ != &::google::protobuf::internal::kEmptyString) {
+    delete str_;
+  }
+  if (str) {
+    set_has_str();
+    str_ = str;
+  } else {
+    clear_has_str();
+    str_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+  }
+}
 
 // required bytes bytes = 2;
 inline bool Message::has_bytes() const {
@@ -704,6 +734,18 @@ inline ::std::string* Message::release_bytes() {
     return temp;
   }
 }
+inline void Message::set_allocated_bytes(::std::string* bytes) {
+  if (bytes_ != &::google::protobuf::internal::kEmptyString) {
+    delete bytes_;
+  }
+  if (bytes) {
+    set_has_bytes();
+    bytes_ = bytes;
+  } else {
+    clear_has_bytes();
+    bytes_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+  }
+}
 
 // optional int32 int32 = 3;
 inline bool Message::has_int32() const {
@@ -895,11 +937,11 @@ inline void Message::clear_e() {
   e_ = 1;
   clear_has_e();
 }
-inline tests::Enum Message::e() const {
-  return static_cast< tests::Enum >(e_);
+inline ::tests::Enum Message::e() const {
+  return static_cast< ::tests::Enum >(e_);
 }
-inline void Message::set_e(tests::Enum value) {
-  GOOGLE_DCHECK(tests::Enum_IsValid(value));
+inline void Message::set_e(::tests::Enum value) {
+  assert(::tests::Enum_IsValid(value));
   set_has_e();
   e_ = value;
 }
@@ -932,6 +974,15 @@ inline ::tests::Nested* Message::release_nested() {
   nested_ = NULL;
   return temp;
 }
+inline void Message::set_allocated_nested(::tests::Nested* nested) {
+  delete nested_;
+  nested_ = nested;
+  if (nested) {
+    set_has_nested();
+  } else {
+    clear_has_nested();
+  }
+}
 
 // repeated string repeated_string = 13;
 inline int Message::repeated_string_size() const {
@@ -1228,15 +1279,15 @@ inline int Message::repeated_enum_size() const {
 inline void Message::clear_repeated_enum() {
   repeated_enum_.Clear();
 }
-inline tests::Enum Message::repeated_enum(int index) const {
-  return static_cast< tests::Enum >(repeated_enum_.Get(index));
+inline ::tests::Enum Message::repeated_enum(int index) const {
+  return static_cast< ::tests::Enum >(repeated_enum_.Get(index));
 }
-inline void Message::set_repeated_enum(int index, tests::Enum value) {
-  GOOGLE_DCHECK(tests::Enum_IsValid(value));
+inline void Message::set_repeated_enum(int index, ::tests::Enum value) {
+  assert(::tests::Enum_IsValid(value));
   repeated_enum_.Set(index, value);
 }
-inline void Message::add_repeated_enum(tests::Enum value) {
-  GOOGLE_DCHECK(tests::Enum_IsValid(value));
+inline void Message::add_repeated_enum(::tests::Enum value) {
+  assert(::tests::Enum_IsValid(value));
   repeated_enum_.Add(value);
 }
 inline const ::google::protobuf::RepeatedField<int>&
@@ -1327,8 +1378,8 @@ namespace google {
 namespace protobuf {
 
 template <>
-inline const EnumDescriptor* GetEnumDescriptor< tests::Enum>() {
-  return tests::Enum_descriptor();
+inline const EnumDescriptor* GetEnumDescriptor< ::tests::Enum>() {
+  return ::tests::Enum_descriptor();
 }
 
 }  // namespace google