xref: /aosp_15_r20/system/core/libprocessgroup/util/include/processgroup/cgroup_controller.h (revision 00c7fec1bb09f3284aad6a6f96d2f63dfc3650ad)
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cstddef>
20 #include <cstdint>
21 #include <string>
22 
23 // Minimal controller description
24 struct CgroupController {
25   public:
26     CgroupController() = default;
27     CgroupController(uint32_t version, uint32_t flags, const std::string& name,
28                      const std::string& path, uint32_t max_activation_depth);
29 
30     uint32_t version() const;
31     uint32_t flags() const;
32     uint32_t max_activation_depth() const;
33     const char* name() const;
34     const char* path() const;
35 
36     void set_flags(uint32_t flags);
37 
38   private:
39     static constexpr size_t CGROUP_NAME_BUF_SZ = 16;
40     static constexpr size_t CGROUP_PATH_BUF_SZ = 32;
41 
42     uint32_t version_ = 0;
43     uint32_t flags_ = 0;
44     uint32_t max_activation_depth_ = UINT32_MAX;
45     char name_[CGROUP_NAME_BUF_SZ] = {};
46     char path_[CGROUP_PATH_BUF_SZ] = {};
47 };