Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
icl::utils::ProcessMonitor Class Reference

The ProcessMonitor class grants access to processes memory and CPU usage. More...

#include <ProcessMonitor.h>

Inheritance diagram for icl::utils::ProcessMonitor:
icl::utils::Thread icl::utils::Uncopyable icl::utils::ShallowCopyable< ThreadImpl, ThreadImplDelOp >

List of all members.

Classes

struct  Info
 Utility struct, that is used to pass available information at once. More...

Public Types

typedef Function< void, const
Info & > 
Callback
 callback function/functor type

Public Member Functions

 ~ProcessMonitor ()
 Destructor.
virtual void run ()
 implements the Thread::run method
Info getInfo () const
 synchronized access to last queried data
int registerCallback (Callback cb)
 registers a callback instance that is automatically called when new data is available
void removeCallback (int id)
 removes a callback registered before
void removeAllCallbacks ()
 removes all registered callbacks

Static Public Member Functions

static ProcessMonitorgetInstance ()
 returns the singelton instance

Protected Member Functions

 ProcessMonitor ()
 Create a new instance.

Private Attributes

Data * m_data
 internal data pointer

Detailed Description

The ProcessMonitor class grants access to processes memory and CPU usage.

Since querying process specific information is not standardized in C++, Only a Linux solution is provided yet.

Source of the Information

The pid is obtained via getpid() numThreads and memoryUsage is obtained by parsing /proc/self/stats memoryUsage is obtained by reading a piped 'ps' processes output since querying information an in particular waiting for 'ps' output takes some time, all the information is collected in a dedicated thread. numCPUs is queried once at construction time by parsing /proc/processor allCPU usage is also queried by parsing the piped 'ps' output

Callbacks

Since sometimes, an application wants to do something, when new information is available, a callback mechanism is provided as well. Simply register an icl::Function instance that is then called whenever a new set of data is available.


Member Typedef Documentation

callback function/functor type


Constructor & Destructor Documentation

Create a new instance.

Destructor.


Member Function Documentation

synchronized access to last queried data

returns the singelton instance

registers a callback instance that is automatically called when new data is available

returns a callback ID

removes all registered callbacks

removes a callback registered before

virtual void icl::utils::ProcessMonitor::run ( ) [virtual]

implements the Thread::run method

Implements icl::utils::Thread.


Member Data Documentation

internal data pointer


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines