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

Function convert

src/posix/rlimits.cpp:35–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33namespace rlimits {
34
35Try<int> convert(RLimitInfo::RLimit::Type type)
36{
37 const Error error(
38 "Resource type '" + RLimitInfo_RLimit_Type_Name(type) +
39 "' not supported");
40
41 switch (type) {
42 // Resource types defined in XSI.
43 case RLimitInfo::RLimit::RLMT_AS: return RLIMIT_AS;
44 case RLimitInfo::RLimit::RLMT_CORE: return RLIMIT_CORE;
45 case RLimitInfo::RLimit::RLMT_CPU: return RLIMIT_CPU;
46 case RLimitInfo::RLimit::RLMT_DATA: return RLIMIT_DATA;
47 case RLimitInfo::RLimit::RLMT_FSIZE: return RLIMIT_FSIZE;
48 case RLimitInfo::RLimit::RLMT_NOFILE: return RLIMIT_NOFILE;
49 case RLimitInfo::RLimit::RLMT_STACK: return RLIMIT_STACK;
50
51 // Resource types also defined on BSDs like e.g., OS X.
52 case RLimitInfo::RLimit::RLMT_MEMLOCK: return RLIMIT_MEMLOCK;
53 case RLimitInfo::RLimit::RLMT_NPROC: return RLIMIT_NPROC;
54 case RLimitInfo::RLimit::RLMT_RSS: return RLIMIT_RSS;
55
56 // Resource types defined in >=Linux 2.6.36.
57 // NOTE: The resource limits defined for Linux are currently the
58 // maximal possible set of understood types. Here we explicitly
59 // list all types and in particular do not use a `default` case,
60 // see MESOS-3754.
61 case RLimitInfo::RLimit::RLMT_LOCKS:
62#ifdef RLIMIT_LOCKS
63 return RLIMIT_LOCKS;
64#else
65 return error;
66#endif
67
68 case RLimitInfo::RLimit::RLMT_MSGQUEUE:
69#ifdef RLIMIT_MSGQUEUE
70 return RLIMIT_MSGQUEUE;
71#else
72 return error;
73#endif
74
75 case RLimitInfo::RLimit::RLMT_NICE:
76#ifdef RLIMIT_NICE
77 return RLIMIT_NICE;
78#else
79 return error;
80#endif
81
82 case RLimitInfo::RLimit::RLMT_RTPRIO:
83#ifdef RLIMIT_RTPRIO
84 return RLIMIT_RTPRIO;
85#else
86 return error;
87#endif
88
89 case RLimitInfo::RLimit::RLMT_RTTIME:
90#ifdef RLIMIT_RTTIME
91 return RLIMIT_RTTIME;
92#else

Callers 15

setFunction · 0.70
getFunction · 0.70
receiveMethod · 0.50
receivedMethod · 0.50
pingMethod · 0.50
executeMethod · 0.50
TestParamMethod · 0.50
convertMethod · 0.50
TEST_FFunction · 0.50
convertToInfoMethod · 0.50
handleRunTaskMessageMethod · 0.50

Calls 1

ErrorFunction · 0.50

Tested by 8

pingMethod · 0.40
executeMethod · 0.40
TestParamMethod · 0.40
convertMethod · 0.40
TEST_FFunction · 0.40
convertToInfoMethod · 0.40
receivedMethod · 0.40
receivedMethod · 0.40