MCPcopy Create free account
hub / github.com/apache/mesos / add

Method add

src/v1/resources.cpp:2203–2230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2201
2202
2203void Resources::add(const Resource_& that)
2204{
2205 if (that.isEmpty()) {
2206 return;
2207 }
2208
2209 bool found = false;
2210 foreach (
2211 Resource_Unsafe& resource_,
2212 resourcesNoMutationWithoutExclusiveOwnership) {
2213 if (internal::addable(resource_->resource, that.resource)) {
2214 // Copy-on-write (if more than 1 reference).
2215 if (resource_.use_count() > 1) {
2216 resource_ = make_shared<Resource_>(*resource_);
2217 }
2218
2219 *resource_ += that;
2220 found = true;
2221 break;
2222 }
2223 }
2224
2225 // Cannot be combined with any existing Resource object.
2226 if (!found) {
2227 resourcesNoMutationWithoutExclusiveOwnership.push_back(
2228 make_shared<Resource_>(that));
2229 }
2230}
2231
2232
2233void Resources::add(Resource_&& that)

Callers 2

foreachFunction · 0.45
parseMethod · 0.45

Calls 1

isEmptyMethod · 0.45

Tested by

no test coverage detected