1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#[derive(Debug)]
#[derive(Serialize, Deserialize)]
pub struct ResourceLimitsSet(HashMap<ResourceName, SoftAndHardResourceLimit>);
impl ResourceLimitsSet
{
#[inline(always)]
pub fn defaultish(maximum_number_of_open_file_descriptors: ResourceLimit) -> Self
{
let _64_000: SoftAndHardResourceLimit = SoftAndHardResourceLimit::both(ResourceLimit::Finite(64_000));
let _262_144: SoftAndHardResourceLimit = SoftAndHardResourceLimit::both(ResourceLimit::Finite(262_144));
let mut map = HashMap::with_capacity(16);
use self::ResourceName::*;
map.insert(MaximumSizeOfFilesThatProcessCanCreateInBytes, SoftAndHardResourceLimit::BothInfinite);
map.insert(MaximumSizeOfVirtualMemoryAddressSpaceInBytes, SoftAndHardResourceLimit::BothInfinite);
map.insert(CpuTimeLimitInSeconds, SoftAndHardResourceLimit::BothInfinite);
map.insert(MaximumNumberOfFileDescriptors, SoftAndHardResourceLimit::both(maximum_number_of_open_file_descriptors));
map.insert(MaximumSizeOfProcessResidentSetSizeInBytes, SoftAndHardResourceLimit::BothInfinite);
map.insert(MaximumNumberOfProcessAndThreads, _64_000);
map.insert(MaximumSizeOfACoreDumpFileInBytes, SoftAndHardResourceLimit::BothZero);
map.insert(MaximumNumberOfBytesForPosixMessageQueues, SoftAndHardResourceLimit::BothZero);
map.insert(MaximumNumberOfBytesThatProcessCanMemLock, SoftAndHardResourceLimit::BothInfinite);
map.insert(MaximumSizeOfProcessStackInBytes, _262_144);
ResourceLimitsSet(map)
}
#[inline(always)]
pub fn change(&self)
{
for (resource_name, soft_and_hard_resource_limit) in &self.0
{
resource_name.set(soft_and_hard_resource_limit);
}
}
}