MCPcopy Create free account
hub / github.com/Kitware/CMake / TryAllocateResources

Method TryAllocateResources

Source/CTest/cmCTestMultiProcessHandler.cxx:367–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367bool cmCTestMultiProcessHandler::TryAllocateResources(
368 int index,
369 std::map<std::string, std::vector<cmCTestBinPackerAllocation>>& allocations,
370 std::map<std::string, ResourceAvailabilityError>* errors)
371{
372 allocations.clear();
373
374 std::size_t processIndex = 0;
375 for (auto const& process : this->Properties[index]->ResourceGroups) {
376 for (auto const& requirement : process) {
377 for (int i = 0; i < requirement.UnitsNeeded; ++i) {
378 allocations[requirement.ResourceType].push_back(
379 { processIndex, requirement.SlotsNeeded, "" });
380 }
381 }
382 ++processIndex;
383 }
384
385 bool result = true;
386 auto const& availableResources = this->ResourceAllocator.GetResources();
387 for (auto& it : allocations) {
388 if (!availableResources.count(it.first)) {
389 if (errors) {
390 (*errors)[it.first] = ResourceAvailabilityError::NoResourceType;
391 result = false;
392 } else {
393 return false;
394 }
395 } else if (!cmAllocateCTestResourcesRoundRobin(
396 availableResources.at(it.first), it.second)) {
397 if (errors) {
398 (*errors)[it.first] = ResourceAvailabilityError::InsufficientResources;
399 result = false;
400 } else {
401 return false;
402 }
403 }
404 }
405
406 return result;
407}
408
409void cmCTestMultiProcessHandler::DeallocateResources(int index)
410{

Callers 2

AllocateResourcesMethod · 0.95

Calls 5

push_backMethod · 0.80
clearMethod · 0.45
countMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected