/Users/deen/code/yugabyte-db/src/yb/util/ulimit.cc
Line | Count | Source |
1 | | // Portions Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | |
13 | | #include "yb/util/ulimit.h" |
14 | | |
15 | | #include <sys/resource.h> |
16 | | |
17 | | namespace yb { |
18 | | |
19 | 675k | ResourceLimit::ResourceLimit(int64_t value) : value_(value) {} |
20 | | |
21 | 205k | std::string ResourceLimit::ToString() const { |
22 | 205k | if (IsUnlimited()) return "unlimited"132k ; |
23 | 73.4k | return std::to_string(value_); |
24 | 205k | } |
25 | | |
26 | 117k | bool ResourceLimit::IsNegative() const { |
27 | 117k | return !IsUnlimited() && value_ < 058.7k ; |
28 | 117k | } |
29 | | |
30 | 835k | bool ResourceLimit::IsUnlimited() const { |
31 | 835k | return value_ == static_cast<int64_t>(RLIM_INFINITY); |
32 | 835k | } |
33 | | |
34 | 29.3k | bool ResourceLimit::operator==(const ResourceLimit& other) const { |
35 | 29.3k | return value_ == other.value_; |
36 | 29.3k | } |
37 | | |
38 | 161k | bool ResourceLimit::operator<(const ResourceLimit& other) const { |
39 | 161k | if (IsUnlimited()) return false75.4k ; |
40 | 86.1k | if (other.IsUnlimited()) return true2.02k ; |
41 | 84.0k | return value_ < other.value_; |
42 | 86.1k | } |
43 | | |
44 | 117k | bool ResourceLimit::operator<=(const ResourceLimit& other) const { |
45 | 117k | return !(other < *this); |
46 | 117k | } |
47 | | |
48 | 102k | int64_t ResourceLimit::RawValue() const { |
49 | 102k | return value_; |
50 | 102k | } |
51 | | |
52 | | } // namespace yb |