Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lxcpp::CGroup Class Reference

#include <cgroup.hpp>

+ Inheritance diagram for lxcpp::CGroup:

Public Member Functions

 CGroup (const std::string &subsys, const std::string &name)
 Define control-group object. More...
 
 CGroup (const std::string &subsysAndCgroup)
 Define control-group object (format "subsys:cgroup_path"). More...
 
bool exists () const
 Check if cgroup exists. More...
 
void create ()
 Create cgroup directory. More...
 
void destroy ()
 Destroy cgroup directory Equivalent of: rmdir subsys.path / mName Note: set memory.force_empty before removing a cgroup to avoid moving out-of-use page caches to parent. More...
 
void setCommonValue (const std::string &param, const std::string &value)
 Set common 'cgroup' parameter. More...
 
std::string getCommonValue (const std::string &param) const
 Get common 'cgroup' paramter. More...
 
void setValue (const std::string &param, const std::string &value)
 Set cgroup parameter to value (name validity depends on subsystem). More...
 
std::string getValue (const std::string &param) const
 Get cgroup parameter. More...
 
void assignGroup (pid_t pid)
 Assign all processes in threadgroup of pid to this cgroup. More...
 
void assignPid (pid_t pid)
 Assign single process to this cgroup (will be removed from previous cgroup automatically). More...
 
std::vector< pid_t > getPids () const
 Get list of pid assigned to this group. More...
 

Static Public Member Functions

static CGroup getCGroup (const std::string &subsys, pid_t pid)
 Get cgroup of process pid in given subsystem. More...
 

Private Attributes

const Subsystem mSubsys
 
const std::string mName
 

Constructor & Destructor Documentation

lxcpp::CGroup::CGroup ( const std::string &  subsys,
const std::string &  name 
)
inline

Define control-group object.

Name can be also considered as path relative to root of subsystem.

lxcpp::CGroup::CGroup ( const std::string &  subsysAndCgroup)

Define control-group object (format "subsys:cgroup_path").

Member Function Documentation

void lxcpp::CGroup::assignGroup ( pid_t  pid)

Assign all processes in threadgroup of pid to this cgroup.

Equivalent of: echo pid > mSubsys_path/mName/cgroup.procs

void lxcpp::CGroup::assignPid ( pid_t  pid)

Assign single process to this cgroup (will be removed from previous cgroup automatically).

Equivalent of: echo pid > mSubsys_path/mName/tasks

void lxcpp::CGroup::create ( )

Create cgroup directory.

Equivalent of: mkdir subsys.path / mName

void lxcpp::CGroup::destroy ( )

Destroy cgroup directory Equivalent of: rmdir subsys.path / mName Note: set memory.force_empty before removing a cgroup to avoid moving out-of-use page caches to parent.

bool lxcpp::CGroup::exists ( ) const

Check if cgroup exists.

Returns
true if cgroup path (subsys.path / mName) exists
CGroup lxcpp::CGroup::getCGroup ( const std::string &  subsys,
pid_t  pid 
)
static

Get cgroup of process pid in given subsystem.

std::string lxcpp::CGroup::getCommonValue ( const std::string &  param) const

Get common 'cgroup' paramter.

Equivalent of: cat mSubsys_path/mName/cgroup.param

std::vector< pid_t > lxcpp::CGroup::getPids ( ) const

Get list of pid assigned to this group.

Equivalent of: cat mSubsys_path/mName/tasks

std::string lxcpp::CGroup::getValue ( const std::string &  param) const

Get cgroup parameter.

Equivalent of: cat mSubsys_path/mName/mSubsys_name.param

void lxcpp::CGroup::setCommonValue ( const std::string &  param,
const std::string &  value 
)

Set common 'cgroup' parameter.

Equivalent of: echo value > mSubsys_path/mName/cgroup.param

void lxcpp::CGroup::setValue ( const std::string &  param,
const std::string &  value 
)

Set cgroup parameter to value (name validity depends on subsystem).

Equivalent of: echo value > mSubsys_path/mName/mSubsys_name.param

Member Data Documentation

const std::string lxcpp::CGroup::mName
private
const Subsystem lxcpp::CGroup::mSubsys
private

The documentation for this class was generated from the following files: