Struct cgroups_rs::Cgroup [−][src]
A control group is the central structure to this crate.
What are control groups?
Lifting over from the Linux kernel sources:
Control Groups provide a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behaviour.
This crate is an attempt at providing a Rust-native way of managing these cgroups.
Implementations
impl Cgroup
[src]
pub fn v2(&self) -> bool
[src]
pub fn new<P: AsRef<Path>>(hier: Box<dyn Hierarchy>, path: P) -> Cgroup
[src]
Create a new control group in the hierarchy hier
, with name path
.
Returns a handle to the control group that can be used to manipulate it.
pub fn new_with_relative_paths<P: AsRef<Path>>(
hier: Box<dyn Hierarchy>,
path: P,
relative_paths: HashMap<String, String>
) -> Cgroup
[src]
hier: Box<dyn Hierarchy>,
path: P,
relative_paths: HashMap<String, String>
) -> Cgroup
Create a new control group in the hierarchy hier
, with name path
and relative_paths
Returns a handle to the control group that can be used to manipulate it.
Note that this method is only meaningful for cgroup v1, call it is equivalent to call new
in the v2 mode
pub fn load<P: AsRef<Path>>(hier: Box<dyn Hierarchy>, path: P) -> Cgroup
[src]
Create a handle for a control group in the hierarchy hier
, with name path
.
Returns a handle to the control group (that possibly does not exist until create()
has
been called on the cgroup.
pub fn load_with_relative_paths<P: AsRef<Path>>(
hier: Box<dyn Hierarchy>,
path: P,
relative_paths: HashMap<String, String>
) -> Cgroup
[src]
hier: Box<dyn Hierarchy>,
path: P,
relative_paths: HashMap<String, String>
) -> Cgroup
Create a handle for a control group in the hierarchy hier
, with name path
and relative_paths
Returns a handle to the control group (that possibly does not exist until create()
has
been called on the cgroup.
Note that this method is only meaningful for cgroup v1, call it is equivalent to call load
in the v2 mode
pub fn subsystems(&self) -> &Vec<Subsystem>
[src]
The list of subsystems that this control group supports.
pub fn delete(&self) -> Result<()>
[src]
Deletes the control group.
Note that this function makes no effort in cleaning up the descendant and the underlying system call will fail if there are any descendants. Thus, one should check whether it was actually removed, and remove the descendants first if not. In the future, this behavior will change.
pub fn apply(&self, res: &Resources) -> Result<()>
[src]
Apply a set of resource limits to the control group.
pub fn controller_of<'a, T>(&'a self) -> Option<&'a T> where
&'a T: From<&'a Subsystem>,
T: Controller + ControllIdentifier,
[src]
&'a T: From<&'a Subsystem>,
T: Controller + ControllIdentifier,
Retrieve a container based on type inference.
Example:
let pids: &PidController = control_group.controller_of()
.expect("No pids controller attached!");
let cpu: &CpuController = control_group.controller_of()
.expect("No cpu controller attached!");
pub fn remove_task(&self, pid: CgroupPid)
[src]
Removes a task from the control group.
Note that this means that the task will be moved back to the root control group in the hierarchy and any rules applied to that control group will still apply to the task.
pub fn add_task(&self, pid: CgroupPid) -> Result<()>
[src]
Attach a task to the control group.
pub fn add_task_by_tgid(&self, pid: CgroupPid) -> Result<()>
[src]
Attach a task to the control group by thread group id.
pub fn set_notify_on_release(&self, enable: bool) -> Result<()>
[src]
Set notify_on_release to the control group.
pub fn set_release_agent(&self, path: &str) -> Result<()>
[src]
Set release_agent
pub fn tasks(&self) -> Vec<CgroupPid>
[src]
Returns an Iterator that can be used to iterate over the tasks that are currently in the control group.
Trait Implementations
impl Clone for Cgroup
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Cgroup
[src]
impl Default for Cgroup
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Cgroup
impl Send for Cgroup
impl Sync for Cgroup
impl Unpin for Cgroup
impl !UnwindSafe for Cgroup
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,