mirror of
https://github.com/mii443/izoli.git
synced 2025-08-22 16:05:40 +00:00
add add_threads
This commit is contained in:
@ -146,15 +146,11 @@ impl CGroup {
|
||||
}
|
||||
|
||||
pub fn add_procs(&self, procs: Vec<u32>) -> Result<(), std::io::Error> {
|
||||
let to_write = procs
|
||||
.iter()
|
||||
.map(|proc| proc.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
self.write_list("cgroup.procs", procs)
|
||||
}
|
||||
|
||||
self.write("cgroup.procs", &to_write)?;
|
||||
|
||||
Ok(())
|
||||
pub fn add_threads(&self, threads: Vec<u32>) -> Result<(), std::io::Error> {
|
||||
self.write_list("cgroup.threads", threads)
|
||||
}
|
||||
|
||||
fn write_value<T>(&self, name: &str, value: T) -> Result<(), std::io::Error>
|
||||
@ -165,6 +161,21 @@ impl CGroup {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_list<T>(&self, name: &str, value: Vec<T>) -> Result<(), std::io::Error>
|
||||
where
|
||||
T: fmt::Display,
|
||||
{
|
||||
let to_write = value
|
||||
.iter()
|
||||
.map(|v| v.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
|
||||
self.write(name, &to_write)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_u32_list(&self, name: &str) -> Result<Vec<u32>, std::io::Error> {
|
||||
let procs = self
|
||||
.read(name)?
|
||||
|
Reference in New Issue
Block a user