You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2018/05/23 23:32:08 UTC

[4/6] mesos git commit: Supported custom error types for the `Future(Try<...>)` constructor.

Supported custom error types for the `Future(Try<...>)` constructor.

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


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

Branch: refs/heads/master
Commit: f8829f87e7220eccbdcf2dec6f5e4a63af0a5a7b
Parents: d7a1fe4
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Thu May 17 12:13:10 2018 -0700
Committer: Chun-Hung Hsiao <ch...@mesosphere.io>
Committed: Wed May 23 16:31:12 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/future.hpp | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f8829f87/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp
index fb107d2..b8508c5 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -42,6 +42,7 @@
 #include <stout/preprocessor.hpp>
 #include <stout/result.hpp>
 #include <stout/result_of.hpp>
+#include <stout/stringify.hpp>
 #include <stout/synchronized.hpp>
 #include <stout/try.hpp>
 
@@ -107,9 +108,11 @@ public:
   /*implicit*/ Future(const Future<T>& that) = default;
   /*implicit*/ Future(Future<T>&& that) = default;
 
-  /*implicit*/ Future(const Try<T>& t);
+  template <typename E>
+  /*implicit*/ Future(const Try<T, E>& t);
 
-  /*implicit*/ Future(const Try<Future<T>>& t);
+  template <typename E>
+  /*implicit*/ Future(const Try<Future<T>, E>& t);
 
   ~Future() = default;
 
@@ -1116,23 +1119,27 @@ Future<T>::Future(const ErrnoFailure& failure)
 
 
 template <typename T>
-Future<T>::Future(const Try<T>& t)
+template <typename E>
+Future<T>::Future(const Try<T, E>& t)
   : data(new Data())
 {
   if (t.isSome()){
     set(t.get());
   } else {
-    fail(t.error());
+    // TODO(chhsiao): Consider preserving the error type. See MESOS-8925.
+    fail(stringify(t.error()));
   }
 }
 
 
 template <typename T>
-Future<T>::Future(const Try<Future<T>>& t)
+template <typename E>
+Future<T>::Future(const Try<Future<T>, E>& t)
   : data(t.isSome() ? t->data : std::shared_ptr<Data>(new Data()))
 {
   if (!t.isSome()) {
-    fail(t.error());
+    // TODO(chhsiao): Consider preserving the error type. See MESOS-8925.
+    fail(stringify(t.error()));
   }
 }