You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2018/01/24 16:44:04 UTC

mesos git commit: Cleaned up interface defintion in duration header.

Repository: mesos
Updated Branches:
  refs/heads/master 8c29938f8 -> 7d16ad06d


Cleaned up interface defintion in duration header.

Move a function definition out of the class
to not clutter the class declaration.

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


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

Branch: refs/heads/master
Commit: 7d16ad06d7ea07515dc435a35b5ff1511c5de645
Parents: 8c29938
Author: Benno Evers <be...@mesosphere.com>
Authored: Wed Jan 24 17:43:09 2018 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Jan 24 17:43:09 2018 +0100

----------------------------------------------------------------------
 3rdparty/stout/include/stout/duration.hpp | 109 +++++++++++++------------
 1 file changed, 56 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7d16ad06/3rdparty/stout/include/stout/duration.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/duration.hpp b/3rdparty/stout/include/stout/duration.hpp
index 930e481..42c43cd 100644
--- a/3rdparty/stout/include/stout/duration.hpp
+++ b/3rdparty/stout/include/stout/duration.hpp
@@ -32,59 +32,7 @@
 class Duration
 {
 public:
-  static Try<Duration> parse(const std::string& s)
-  {
-    // TODO(benh): Support negative durations (i.e., starts with '-').
-    size_t index = 0;
-    while (index < s.size()) {
-      if (isdigit(s[index]) || s[index] == '.') {
-        index++;
-        continue;
-      }
-
-      Try<double> value = numify<double>(s.substr(0, index));
-
-      if (value.isError()) {
-        return Error(value.error());
-      }
-
-      const std::string unit = s.substr(index);
-
-      int64_t factor;
-      if (unit == "ns") {
-        factor = NANOSECONDS;
-      } else if (unit == "us") {
-        factor = MICROSECONDS;
-      } else if (unit == "ms") {
-        factor = MILLISECONDS;
-      } else if (unit == "secs") {
-        factor = SECONDS;
-      } else if (unit == "mins") {
-        factor = MINUTES;
-      } else if (unit == "hrs") {
-        factor = HOURS;
-      } else if (unit == "days") {
-        factor = DAYS;
-      } else if (unit == "weeks") {
-        factor = WEEKS;
-      } else {
-        return Error(
-            "Unknown duration unit '" + unit + "'; supported units are"
-            " 'ns', 'us', 'ms', 'secs', 'mins', 'hrs', 'days', and 'weeks'");
-      }
-
-      double nanos = value.get() * factor;
-      if (nanos > max().nanos || nanos < min().nanos) {
-        return Error(
-            "Argument out of the range that a Duration can represent due"
-            " to int64_t's size limit");
-      }
-
-      return Duration(value.get(), factor);
-    }
-
-    return Error("Invalid duration '" + s + "'");
-  }
+  static Try<Duration> parse(const std::string& s);
 
   static Try<Duration> create(double seconds);
 
@@ -412,6 +360,61 @@ inline std::ostream& operator<<(std::ostream& stream, const Duration& duration_)
 }
 
 
+inline Try<Duration> Duration::parse(const std::string& s)
+{
+  // TODO(benh): Support negative durations (i.e., starts with '-').
+  size_t index = 0;
+  while (index < s.size()) {
+    if (isdigit(s[index]) || s[index] == '.') {
+      index++;
+      continue;
+    }
+
+    Try<double> value = numify<double>(s.substr(0, index));
+
+    if (value.isError()) {
+      return Error(value.error());
+    }
+
+    const std::string unit = s.substr(index);
+
+    int64_t factor;
+    if (unit == "ns") {
+      factor = NANOSECONDS;
+    } else if (unit == "us") {
+      factor = MICROSECONDS;
+    } else if (unit == "ms") {
+      factor = MILLISECONDS;
+    } else if (unit == "secs") {
+      factor = SECONDS;
+    } else if (unit == "mins") {
+      factor = MINUTES;
+    } else if (unit == "hrs") {
+      factor = HOURS;
+    } else if (unit == "days") {
+      factor = DAYS;
+    } else if (unit == "weeks") {
+      factor = WEEKS;
+    } else {
+      return Error(
+          "Unknown duration unit '" + unit + "'; supported units are"
+          " 'ns', 'us', 'ms', 'secs', 'mins', 'hrs', 'days', and 'weeks'");
+    }
+
+    double nanos = value.get() * factor;
+    if (nanos > max().nanos || nanos < min().nanos) {
+      return Error(
+          "Argument out of the range that a Duration can represent due"
+          " to int64_t's size limit");
+    }
+
+    return Duration(value.get(), factor);
+  }
+
+  return Error("Invalid duration '" + s + "'");
+}
+
+
 inline Try<Duration> Duration::create(double seconds)
 {
   if (seconds * SECONDS > max().nanos || seconds * SECONDS < min().nanos) {