MainLoop Class Reference

class implementing a main loop with glib More...

#include <main_loop.h>

List of all members.

Public Member Functions

 MainLoop ()
 constructor initializing the MainLoop object
void run ()
 runs the main loop
void quit ()
 quits the main loop
void updateCallbacks ()
 updates all callbacks within the main loop
int addCallback (int interval, gboolean(*function)(gpointer data))
 adds a callback to the main loop

Private Member Functions

void setupCallbacks ()
 adds callbacks to the main loop

Static Private Member Functions

static gboolean hwEvent_callback (GIOChannel *io_channel, GIOCondition io_condition, gpointer data)
 callback for events on acpi/apm event file
static gboolean hwEvent_reconnect (gpointer data)
 callback for reconnection to the hwEvent channel
static gboolean hwEvent_connect ()
 connects to the hw event file (apm/acpi)
static gboolean checkThrottling_callback (gpointer data)
 callback for updating the cpu state inside PM_interface
static gboolean checkEventTimeouts_callback (gpointer data)
 callback for checking pending powersave events
static gboolean adjustSpeeds_callback (gpointer data)
 callback for adjust cpu speed in case of cpufreq userspace

Private Attributes

GMainLoop * _gmain
 gmain loop object
std::list< Callback_callback_functions
 list storing all added callbacks
DBus_Server _dbus_server


Detailed Description

class implementing a main loop with glib

Cares about callbacks and executes appropriate functions from PM_Interface


Constructor & Destructor Documentation

MainLoop::MainLoop  ) 
 

constructor initializing the MainLoop object

Constructor setting up the dbus connection and the gmain loop. For running the main loop, you have to call run().


Member Function Documentation

int MainLoop::addCallback int  interval,
gboolean(*)(gpointer data)  function
 

adds a callback to the main loop

adds a callback function with the given interval to the gmain loop

Parameters:
interval interval on which the function should be called
function the function pointer serving as callback

gboolean MainLoop::adjustSpeeds_callback gpointer  data  )  [static, private]
 

callback for adjust cpu speed in case of cpufreq userspace

calls CPUFreq::adjustSpeeds

If cpu, function returns false is not called again

Parameters:
data user data
Returns:
true on success, false otherwise. If false, the callback is never called again.

gboolean MainLoop::checkEventTimeouts_callback gpointer  data  )  [static, private]
 

callback for checking pending powersave events

calls pm->checkEventTimeouts();

Parameters:
data user data
Returns:
true on success, false otherwise. If false, the callback is never called again.

gboolean MainLoop::checkThrottling_callback gpointer  data  )  [static, private]
 

callback for updating the cpu state inside PM_interface

calls pm->updateCPUState();

Returns:
true on success, false otherwise. If false, the callback is never called again.

gboolean MainLoop::hwEvent_callback GIOChannel *  io_channel,
GIOCondition  io_condition,
gpointer  data
[static, private]
 

callback for events on acpi/apm event file

Function is called whenever there is an event on the hw event filedescriptor. Defined static to be used as gmain loop callback

Parameters:
io_channel the io channel used by glib
io_condition conditions on what we listen
data user data
Returns:
true on success, false otherwise. If false, the callback is not called again until readded

gboolean MainLoop::hwEvent_connect  )  [static, private]
 

connects to the hw event file (apm/acpi)

Function is called successively when hw event channel broke away. Defined static to be used inside static callback functions.

Returns:
true on success, false otherwise.

gboolean MainLoop::hwEvent_reconnect gpointer  data  )  [static, private]
 

callback for reconnection to the hwEvent channel

Function is called successively when hw event channel broke away until it is back again.. Defined static to be used as gmain loop callback

Parameters:
data user data
Returns:
true on success, false otherwise. If false, the callback is never called again

void MainLoop::quit  ) 
 

quits the main loop

void MainLoop::run  ) 
 

runs the main loop

Runs the main loop and blocks until quit() is called.

void MainLoop::setupCallbacks  )  [private]
 

adds callbacks to the main loop

Adds the default callbacks to the main loop.

void MainLoop::updateCallbacks  ) 
 

updates all callbacks within the main loop

Updates all callbacks within the main loop. If a callback already exists, do nothing. This function should be called whenever there is a config/scheme/hardware change. It needs less ressources, so it is no problem to call it as often as needed.


Member Data Documentation

std::list<Callback> MainLoop::_callback_functions [private]
 

list storing all added callbacks

DBus_Server MainLoop::_dbus_server [private]
 

GMainLoop* MainLoop::_gmain [private]
 

gmain loop object


The documentation for this class was generated from the following files:
Generated on Mon Mar 27 09:27:20 2006 for Powersave Daemon by  doxygen 1.4.6