dbus-cxx logo
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
DBus::Dispatcher Class Reference

Handles multi-threaded dispatching of one or more connections. More...

#include <dispatcher.h>

Inheritance diagram for DBus::Dispatcher:
Inheritance graph
[legend]

Public Types

typedef DBusCxxPointer
< Dispatcher
pointer
typedef DBusCxxPointer< const
Dispatcher
const_pointer

Public Member Functions

virtual ~Dispatcher ()
bool start ()
bool stop ()
bool is_running ()
struct timeval & responsiveness ()
void set_responsiveness (const struct timeval &r)
void set_responsiveness (time_t sec, suseconds_t usec)
Managing Connections
Connection::pointer create_connection (DBusConnection *cobj=NULL, bool is_private=false)
Connection::pointer create_connection (BusType type, bool is_private=false)
Connection::pointer create_connection (const Connection &other)
bool add_connection (Connection::pointer connection)

Static Public Member Functions

static pointer create (bool is_running=true)

Protected Types

typedef std::list
< Connection::pointer
Connections

Protected Member Functions

 Dispatcher (bool is_running=true)
void build_read_fd_set ()
void build_write_fd_set ()
virtual void dispatch_thread_main ()
void watch_thread_main ()
bool on_add_watch (Watch::pointer)
bool on_remove_watch (Watch::pointer)
bool on_watch_toggled (Watch::pointer)
bool on_add_timeout (Timeout::pointer)
bool on_remove_timeout (Timeout::pointer)
bool on_timeout_toggled (Timeout::pointer)
void on_wakeup_main (Connection::pointer)
void on_dispatch_status_changed (DispatchStatus, Connection::pointer)

Static Protected Member Functions

static void * proxy_dispatch_thread_main (void *)
 Since pthread_create cannot take a class method as the thread-main parameter this function is called with an argument pointing to the Dispatcher instance to start in the thread.
static void * proxy_watch_thread_main (void *)
 Since pthread_create cannot take a class method as the thread-main parameter this function is called with an argument pointing to the Dispatcher instance to start in the thread.

Protected Attributes

Connections m_connections
bool m_running
pthread_t m_dispatch_thread
pthread_t m_watch_thread
pthread_mutex_t m_mutex_read_watches
std::map< int, Watch::pointerm_read_watches
std::set< int > m_enabled_read_fds
fd_set m_read_fd_set
int m_maximum_read_fd
pthread_mutex_t m_mutex_write_watches
std::map< int, Watch::pointerm_write_watches
std::set< int > m_enabled_write_fds
fd_set m_write_fd_set
int m_maximum_write_fd
fd_set m_exception_fd_set
pthread_mutex_t m_mutex_exception_fd_set
struct timeval m_responsiveness
unsigned int m_dispatch_loop_limit
 This is the maximum number of dispatches that will occur for a connection in one iteration of the dispatch thread.
bool m_initiate_processing
pthread_cond_t m_cond_initiate_processing
pthread_mutex_t m_mutex_initiate_processing

Detailed Description

Handles multi-threaded dispatching of one or more connections.

This class provides a way to handle multiple connections with one set of dispatching threads.

This dispatcher creates two threads, one to watch I/O file descriptors for activity and the other to handle message dispatching.

Author
Rick L Vinyard Jr rviny.nosp@m.ard@.nosp@m.cs.nm.nosp@m.su.e.nosp@m.du

Member Typedef Documentation

typedef std::list<Connection::pointer> DBus::Dispatcher::Connections
protected
typedef DBusCxxPointer<const Dispatcher> DBus::Dispatcher::const_pointer
typedef DBusCxxPointer<Dispatcher> DBus::Dispatcher::pointer

Constructor & Destructor Documentation

DBus::Dispatcher::Dispatcher ( bool  is_running = true)
protected
DBus::Dispatcher::~Dispatcher ( )
virtual

Member Function Documentation

bool DBus::Dispatcher::add_connection ( Connection::pointer  connection)
void DBus::Dispatcher::build_read_fd_set ( )
protected
void DBus::Dispatcher::build_write_fd_set ( )
protected
Dispatcher::pointer DBus::Dispatcher::create ( bool  is_running = true)
static
Connection::pointer DBus::Dispatcher::create_connection ( DBusConnection *  cobj = NULL,
bool  is_private = false 
)

References add_connection(), and create().

Connection::pointer DBus::Dispatcher::create_connection ( BusType  type,
bool  is_private = false 
)

References add_connection(), and create().

Connection::pointer DBus::Dispatcher::create_connection ( const Connection other)

References add_connection(), and create().

void DBus::Dispatcher::dispatch_thread_main ( )
protectedvirtual
bool DBus::Dispatcher::is_running ( )
bool DBus::Dispatcher::on_add_timeout ( Timeout::pointer  timeout)
protected

References DBUS_CXX_DEBUG.

Referenced by add_connection().

bool DBus::Dispatcher::on_add_watch ( Watch::pointer  watch)
protected
void DBus::Dispatcher::on_dispatch_status_changed ( DispatchStatus  status,
Connection::pointer  conn 
)
protected
bool DBus::Dispatcher::on_remove_timeout ( Timeout::pointer  timeout)
protected

References DBUS_CXX_DEBUG.

Referenced by add_connection().

bool DBus::Dispatcher::on_remove_watch ( Watch::pointer  watch)
protected
bool DBus::Dispatcher::on_timeout_toggled ( Timeout::pointer  timeout)
protected

References DBUS_CXX_DEBUG.

Referenced by add_connection().

void DBus::Dispatcher::on_wakeup_main ( Connection::pointer  conn)
protected
bool DBus::Dispatcher::on_watch_toggled ( Watch::pointer  watch)
protected
void * DBus::Dispatcher::proxy_dispatch_thread_main ( void *  arg)
staticprotected

Since pthread_create cannot take a class method as the thread-main parameter this function is called with an argument pointing to the Dispatcher instance to start in the thread.

References dispatch_thread_main().

Referenced by start().

void * DBus::Dispatcher::proxy_watch_thread_main ( void *  arg)
staticprotected

Since pthread_create cannot take a class method as the thread-main parameter this function is called with an argument pointing to the Dispatcher instance to start in the thread.

References watch_thread_main().

Referenced by start().

struct timeval & DBus::Dispatcher::responsiveness ( )
read

References m_responsiveness.

void DBus::Dispatcher::set_responsiveness ( const struct timeval &  r)

References m_responsiveness.

void DBus::Dispatcher::set_responsiveness ( time_t  sec,
suseconds_t  usec 
)

References m_responsiveness.

bool DBus::Dispatcher::start ( )
bool DBus::Dispatcher::stop ( )
void DBus::Dispatcher::watch_thread_main ( )
protected

Member Data Documentation

pthread_cond_t DBus::Dispatcher::m_cond_initiate_processing
protected
Connections DBus::Dispatcher::m_connections
protected
unsigned int DBus::Dispatcher::m_dispatch_loop_limit
protected

This is the maximum number of dispatches that will occur for a connection in one iteration of the dispatch thread.

If set to 0, a particular connection will continue to dispatch as long as its status remains DISPATCH_DATA_REMAINS.

Referenced by dispatch_thread_main(), and DBus::Glib::Dispatcher::on_glibmm_dispatch().

pthread_t DBus::Dispatcher::m_dispatch_thread
protected

Referenced by start(), and stop().

std::set<int> DBus::Dispatcher::m_enabled_read_fds
protected
std::set<int> DBus::Dispatcher::m_enabled_write_fds
protected
fd_set DBus::Dispatcher::m_exception_fd_set
protected

Referenced by Dispatcher().

bool DBus::Dispatcher::m_initiate_processing
protected
int DBus::Dispatcher::m_maximum_read_fd
protected
int DBus::Dispatcher::m_maximum_write_fd
protected
pthread_mutex_t DBus::Dispatcher::m_mutex_exception_fd_set
protected
pthread_mutex_t DBus::Dispatcher::m_mutex_initiate_processing
protected
pthread_mutex_t DBus::Dispatcher::m_mutex_read_watches
protected
pthread_mutex_t DBus::Dispatcher::m_mutex_write_watches
protected
fd_set DBus::Dispatcher::m_read_fd_set
protected
std::map<int, Watch::pointer> DBus::Dispatcher::m_read_watches
protected
struct timeval DBus::Dispatcher::m_responsiveness
protected
bool DBus::Dispatcher::m_running
protected
pthread_t DBus::Dispatcher::m_watch_thread
protected

Referenced by start(), and stop().

fd_set DBus::Dispatcher::m_write_fd_set
protected
std::map<int, Watch::pointer> DBus::Dispatcher::m_write_watches
protected

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

Generated on Sat Sep 21 2013 17:22:40 for dbus-cxx by doxygen 1.8.1.2