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/25 01:14:47 UTC

[6/7] git commit: Added a conversion constructor to Future.

Added a conversion constructor to Future.

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


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

Branch: refs/heads/master
Commit: df8ffd01ce694ef6d45ee2b41b1334ab74d93ccf
Parents: 48e663e
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sat Jan 18 10:17:20 2014 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Fri Jan 24 16:14:01 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/future.hpp | 52 +++++++++++++--------
 1 file changed, 32 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/df8ffd01/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp
index 2a5f124..aaf17af 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -51,6 +51,9 @@ class Promise;
 template <typename T>
 class WeakFuture;
 
+// Forward declaration of Failure.
+struct Failure;
+
 
 // Definition of a "shared" future. A future can hold any
 // copy-constructible value. A future is considered "shared" because
@@ -63,8 +66,16 @@ public:
   static Future<T> failed(const std::string& message);
 
   Future();
+
   Future(const T& _t);
+
+  template <typename U>
+  Future(const U& u);
+
+  Future(const Failure& failure);
+
   Future(const Future<T>& that);
+
   ~Future();
 
   // Futures are assignable (and copyable). This results in the
@@ -490,33 +501,17 @@ void discard(WeakFuture<T> reference)
 
 } // namespace internal {
 
+
 // Helper for creating failed futures.
-struct _Failure
+struct Failure
 {
-  _Failure(const std::string& _message) : message(_message) {}
-
-  template <typename T>
-  operator Future<T> () const
-  {
-    return Future<T>::failed(message);
-  }
+  Failure(const std::string& _message) : message(_message) {}
+  Failure(const Error& error) : message(error.message) {}
 
   const std::string message;
 };
 
 
-inline _Failure Failure(const std::string& message)
-{
-  return _Failure(message);
-}
-
-
-inline _Failure Failure(const Error& error)
-{
-  return _Failure(error.message);
-}
-
-
 // TODO(benh): Make Promise a subclass of Future?
 template <typename T>
 class Promise
@@ -801,6 +796,23 @@ Future<T>::Future(const T& _t)
 
 
 template <typename T>
+template <typename U>
+Future<T>::Future(const U& u)
+  : data(new Data())
+{
+  set(u);
+}
+
+
+template <typename T>
+Future<T>::Future(const Failure& failure)
+  : data(new Data())
+{
+  fail(failure.message);
+}
+
+
+template <typename T>
 Future<T>::Future(const Future<T>& that)
   : data(that.data) {}