From c254fffbe0defa8946b7385b2cd92e7453b82e1d Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Thu, 3 Dec 2020 17:53:46 +0800 Subject: [PATCH] Update readme Update readme Signed-off-by: Tim Zhang --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index da0754e..6f26f5c 100644 --- a/README.md +++ b/README.md @@ -9,24 +9,29 @@ is planned for the Unified hierarchy. ## Create a control group using the builder pattern ``` rust -// Acquire a handle for the V1 cgroup hierarchy. -let hier = ::hierarchies::V1::new(); + + +use cgroups::*; +use cgroups::cgroup_builder::*; + +// Acquire a handle for the cgroup hierarchy. +let hier = cgroups::hierarchies::auto(); // Use the builder pattern (see the documentation to create the control group) // // This creates a control group named "example" in the V1 hierarchy. -let cg: Cgroup = CgroupBuilder::new("example", &v1) - .cpu() - .shares(85) - .done() - .build(); + let cg: Cgroup = CgroupBuilder::new("example") + .cpu() + .shares(85) + .done() + .build(hier); // Now `cg` is a control group that gets 85% of the CPU time in relative to // other control groups. // Get a handle to the CPU controller. -let cpus: &CpuController = cg.controller_of().unwrap(); -cpus.add_task(1234u64); +let cpus: &cgroups::cpu::CpuController = cg.controller_of().unwrap(); +cpus.add_task(&CgroupPid::from(1234u64)); // [...]