Enable move semantics for Future and Promise.

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


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

Branch: refs/heads/master
Commit: 2a81c7f091dbc0fdb7bc7bb5eac501848698fbb6
Parents: fb0a6d9
Author: Michael Park <[email protected]>
Authored: Sun Jun 14 03:27:12 2015 -0700
Committer: Benjamin Hindman <[email protected]>
Committed: Sun Jun 14 04:12:02 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/future.hpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2a81c7f0/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp 
b/3rdparty/libprocess/include/process/future.hpp
index 75cbe12..adfad6f 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -10,6 +10,7 @@
 #include <memory> // TODO(benh): Replace shared_ptr with unique_ptr.
 #include <set>
 #include <type_traits>
+#include <utility>
 #include <vector>
 
 #include <glog/logging.h>
@@ -88,6 +89,8 @@ public:
 
   /*implicit*/ Future(const Future<T>& that);
 
+  /*implicit*/ Future(Future<T>&& that);
+
   /*implicit*/ Future(const Try<T>& t);
 
   ~Future();
@@ -487,6 +490,8 @@ public:
   explicit Promise(const T& t);
   virtual ~Promise();
 
+  Promise(Promise<T>&& that);
+
   bool discard();
   bool set(const T& _t);
   bool set(const Future<T>& future); // Alias for associate.
@@ -568,6 +573,11 @@ Promise<T>::~Promise()
 
 
 template <typename T>
+Promise<T>::Promise(Promise<T>&& that)
+  : f(std::move(that.f)) {}
+
+
+template <typename T>
 bool Promise<T>::discard()
 {
   if (!f.data->associated) {
@@ -857,6 +867,11 @@ Future<T>::Future(const Future<T>& that)
 
 
 template <typename T>
+Future<T>::Future(Future<T>&& that)
+  : data(std::move(that.data)) {}
+
+
+template <typename T>
 Future<T>::Future(const Try<T>& t)
   : data(new Data())
 {

Reply via email to