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 2015/06/14 11:46:24 UTC
[06/21] mesos git commit: libprocess: Rebased for _CheckFatal changes
in stout.
libprocess: Rebased for _CheckFatal changes in stout.
Review: https://reviews.apache.org/r/35423
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c683b00b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c683b00b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c683b00b
Branch: refs/heads/master
Commit: c683b00bc7a01099f0ef614606b053e9b4fbb94f
Parents: 5f7c5a7
Author: Michael Park <mc...@gmail.com>
Authored: Sat Jun 13 05:25:03 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sun Jun 14 02:43:00 2015 -0700
----------------------------------------------------------------------
3rdparty/libprocess/include/process/check.hpp | 67 ++++++++++------------
1 file changed, 29 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c683b00b/3rdparty/libprocess/include/process/check.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/check.hpp b/3rdparty/libprocess/include/process/check.hpp
index 60989ac..4b43b70 100644
--- a/3rdparty/libprocess/include/process/check.hpp
+++ b/3rdparty/libprocess/include/process/check.hpp
@@ -25,79 +25,69 @@
// This appends the error if possible to the end of the log message, so there's
// no need to append the error message explicitly.
#define CHECK_PENDING(expression) \
- for (const Option<std::string> _error = _checkPending(expression); \
- _error.isSome();) \
- _CheckFatal(__FILE__, __LINE__, "CHECK_PENDING", \
- #expression, _error.get()).stream()
+ CHECK_STATE(CHECK_PENDING, _check_pending, expression)
#define CHECK_READY(expression) \
- for (const Option<std::string> _error = _checkReady(expression); \
- _error.isSome();) \
- _CheckFatal(__FILE__, __LINE__, "CHECK_READY", \
- #expression, _error.get()).stream()
+ CHECK_STATE(CHECK_READY, _check_ready, expression)
#define CHECK_DISCARDED(expression) \
- for (const Option<std::string> _error = _checkDiscarded(expression); \
- _error.isSome();) \
- _CheckFatal(__FILE__, __LINE__, "CHECK_DISCARDED", \
- #expression, _error.get()).stream()
+ CHECK_STATE(CHECK_DISCARDED, _check_discarded, expression)
#define CHECK_FAILED(expression) \
- for (const Option<std::string> _error = _checkFailed(expression); \
- _error.isSome();) \
- _CheckFatal(__FILE__, __LINE__, "CHECK_FAILED", \
- #expression, _error.get()).stream()
-
+ CHECK_STATE(CHECK_FAILED, _check_failed, expression)
// Private structs/functions used for CHECK_*.
template <typename T>
-Option<std::string> _checkPending(const process::Future<T>& f)
+Option<Error> _check_pending(const process::Future<T>& f)
{
if (f.isReady()) {
- return Some("is READY");
+ return Error("is READY");
} else if (f.isDiscarded()) {
- return Some("is DISCARDED");
+ return Error("is DISCARDED");
} else if (f.isFailed()) {
- return Some("is FAILED: " + f.failure());
+ return Error("is FAILED: " + f.failure());
+ } else {
+ CHECK(f.isPending());
+ return None();
}
- CHECK(f.isPending());
- return None();
}
template <typename T>
-Option<std::string> _checkReady(const process::Future<T>& f)
+Option<Error> _check_ready(const process::Future<T>& f)
{
if (f.isPending()) {
- return Some("is PENDING");
+ return Error("is PENDING");
} else if (f.isDiscarded()) {
- return Some("is DISCARDED");
+ return Error("is DISCARDED");
} else if (f.isFailed()) {
- return Some("is FAILED: " + f.failure());
+ return Error("is FAILED: " + f.failure());
+ } else {
+ CHECK(f.isReady());
+ return None();
}
- CHECK(f.isReady());
- return None();
}
template <typename T>
-Option<std::string> _checkDiscarded(const process::Future<T>& f)
+Option<Error> _check_discarded(const process::Future<T>& f)
{
if (f.isPending()) {
- return Some("is PENDING");
+ return Error("is PENDING");
} else if (f.isReady()) {
- return Some("is READY");
+ return Error("is READY");
} else if (f.isFailed()) {
- return Some("is FAILED: " + f.failure());
+ return Error("is FAILED: " + f.failure());
+ } else {
+ CHECK(f.isDiscarded());
+ return None();
}
- CHECK(f.isDiscarded());
- return None();
}
template <typename T>
-Option<std::string> _checkFailed(const process::Future<T>& f)
+Option<Error> _check_failed(const process::Future<T>& f)
{
if (f.isPending()) {
return Some("is PENDING");
@@ -105,9 +95,10 @@ Option<std::string> _checkFailed(const process::Future<T>& f)
return Some("is READY");
} else if (f.isDiscarded()) {
return Some("is DISCARDED");
+ } else {
+ CHECK(f.isFailed());
+ return None();
}
- CHECK(f.isFailed());
- return None();
}
// TODO(dhamon): CHECK_NPENDING, CHECK_NREADY, etc.