Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/CTest/cmCTestResourceAllocator.h
4998 views
1
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2
file LICENSE.rst or https://cmake.org/licensing for details. */
3
#pragma once
4
5
#include <map>
6
#include <string>
7
8
class cmCTestResourceSpec;
9
10
class cmCTestResourceAllocator
11
{
12
public:
13
struct Resource
14
{
15
unsigned int Total;
16
unsigned int Locked;
17
18
unsigned int Free() const { return this->Total - this->Locked; }
19
20
friend bool operator==(Resource left, Resource right)
21
{
22
return left.Total == right.Total && left.Locked == right.Locked;
23
}
24
25
friend bool operator!=(Resource left, Resource right)
26
{
27
return !(left == right);
28
}
29
};
30
31
void InitializeFromResourceSpec(cmCTestResourceSpec const& spec);
32
33
std::map<std::string, std::map<std::string, Resource>> const& GetResources()
34
const;
35
36
bool AllocateResource(std::string const& name, std::string const& id,
37
unsigned int slots);
38
bool DeallocateResource(std::string const& name, std::string const& id,
39
unsigned int slots);
40
41
private:
42
std::map<std::string, std::map<std::string, Resource>> Resources;
43
};
44
45