You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mz...@apache.org on 2019/06/07 00:37:08 UTC
[mesos] 01/03: Added `<<` operator for `ResourceLimits`.
This is an automated email from the ASF dual-hosted git repository.
mzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 226a9d8b49dbac7118059e3ed2f3c635579da5fb
Author: Meng Zhu <mz...@mesosphere.io>
AuthorDate: Mon Jun 3 19:55:32 2019 -0700
Added `<<` operator for `ResourceLimits`.
Review: https://reviews.apache.org/r/70779
---
src/common/resource_quantities.cpp | 66 +++++++++++++++++++++++++-------------
src/common/resource_quantities.hpp | 3 ++
2 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/src/common/resource_quantities.cpp b/src/common/resource_quantities.cpp
index f79b678..1aaa0d7 100644
--- a/src/common/resource_quantities.cpp
+++ b/src/common/resource_quantities.cpp
@@ -350,28 +350,6 @@ void ResourceQuantities::add(const string& name, const double value)
}
-ostream& operator<<(
- ostream& stream,
- const ResourceQuantities& quantities)
-{
- if (quantities.begin() == quantities.end()) {
- stream << "{}";
- return stream;
- }
-
- auto it = quantities.begin();
-
- while (it != quantities.end()) {
- stream << it->first << ':' << it->second;
- if (++it != quantities.end()) {
- stream << "; ";
- }
- }
-
- return stream;
-}
-
-
// This function tries to be consistent with `Resources::fromSimpleString()`.
// We trim the whitespace around the pair and in the number but whitespace in
// "c p us:10" are preserved and will be parsed to {"c p us", 10}.
@@ -598,5 +576,49 @@ void ResourceLimits::set(
}
+ostream& operator<<(
+ ostream& stream,
+ const ResourceQuantities& quantities)
+{
+ if (quantities.begin() == quantities.end()) {
+ stream << "{}";
+ return stream;
+ }
+
+ auto it = quantities.begin();
+
+ while (it != quantities.end()) {
+ stream << it->first << ':' << it->second;
+ if (++it != quantities.end()) {
+ stream << "; ";
+ }
+ }
+
+ return stream;
+}
+
+
+ostream& operator<<(
+ ostream& stream,
+ const ResourceLimits& limits)
+{
+ if (limits.begin() == limits.end()) {
+ stream << "{}";
+ return stream;
+ }
+
+ auto it = limits.begin();
+
+ while (it != limits.end()) {
+ stream << it->first << ':' << it->second;
+ if (++it != limits.end()) {
+ stream << "; ";
+ }
+ }
+
+ return stream;
+}
+
+
} // namespace internal {
} // namespace mesos {
diff --git a/src/common/resource_quantities.hpp b/src/common/resource_quantities.hpp
index 538256b..af7da8b 100644
--- a/src/common/resource_quantities.hpp
+++ b/src/common/resource_quantities.hpp
@@ -257,6 +257,9 @@ private:
};
+std::ostream& operator<<(std::ostream& stream, const ResourceLimits& limits);
+
+
} // namespace internal {
} // namespace mesos {