mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [mesos] branch master updated: Added move support for `class Resource_`.
Date Fri, 03 Aug 2018 21:35:47 GMT
This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new eaf1b7a  Added move support for `class Resource_`.
eaf1b7a is described below

commit eaf1b7a360567b25bdcdf4fd23c7b78215668bd3
Author: Meng Zhu <mzhu@mesosphere.io>
AuthorDate: Fri Aug 3 14:35:32 2018 -0700

    Added move support for `class Resource_`.
    
    Review: https://reviews.apache.org/r/68196/
---
 include/mesos/resources.hpp    | 16 ++++++++++++++++
 include/mesos/v1/resources.hpp | 15 +++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index 175833c..21aaf0d 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -100,6 +100,22 @@ private:
       }
     }
 
+    /*implicit*/ Resource_(Resource&& _resource)
+      : resource(std::move(_resource)),
+        sharedCount(None())
+    {
+      // Setting the counter to 1 to denote "one copy" of the shared resource.
+      if (resource.has_shared()) {
+        sharedCount = 1;
+      }
+    }
+
+    Resource_(const Resource_& resource_) = default;
+    Resource_(Resource_&& resource_) = default;
+
+    Resource_& operator=(const Resource_&) = default;
+    Resource_& operator=(Resource_&&) = default;
+
     // By implicitly converting to Resource we are able to keep Resource_
     // logic internal and expose only the protobuf object.
     operator const Resource&() const { return resource; }
diff --git a/include/mesos/v1/resources.hpp b/include/mesos/v1/resources.hpp
index b607b68..2f9c704 100644
--- a/include/mesos/v1/resources.hpp
+++ b/include/mesos/v1/resources.hpp
@@ -100,6 +100,21 @@ private:
       }
     }
 
+    /*implicit*/ Resource_(Resource&& _resource)
+      : resource(std::move(_resource)), sharedCount(None())
+    {
+      // Setting the counter to 1 to denote "one copy" of the shared resource.
+      if (resource.has_shared()) {
+        sharedCount = 1;
+      }
+    }
+
+    Resource_(const Resource_& resource_) = default;
+    Resource_(Resource_&& resource_) = default;
+
+    Resource_& operator=(const Resource_&) = default;
+    Resource_& operator=(Resource_&&) = default;
+
     // By implicitly converting to Resource we are able to keep Resource_
     // logic internal and expose only the protobuf object.
     operator const Resource&() const { return resource; }


Mime
View raw message