dbus-cxx logo
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | 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 ()
 
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)
 
virtual void dispatch_thread_main ()
 
bool on_add_watch (Watch::pointer)
 
bool on_remove_watch (Watch::pointer)
 
void 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)
 
void wakeup_thread ()
 
void add_read_and_write_watches (std::vector< struct pollfd > *fds)
 Add all read and write watch FDs to the given vector to watch. More...
 
void handle_read_and_write_watches (std::vector< struct pollfd > *fds)
 Handle all of the read and write watches if the given FD needs to be serviced. More...
 
void dispatch_connections ()
 Dispatch all of our connections. More...
 

Protected Attributes

Connections m_connections
 
bool m_running
 
std::thread * m_dispatch_thread
 
std::mutex m_mutex_watches
 
std::list< Watch::pointerm_watches
 
std::map< int, Watch::pointerm_watches_map
 
std::mutex m_mutex_exception_fd_set
 
std::vector< int > m_exception_fd_set
 
int process_fd [2]
 
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. More...
 

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

References process_fd, and start().

Referenced by create().

DBus::Dispatcher::~Dispatcher ( )
virtual

Reimplemented in DBus::Glib::Dispatcher.

References is_running(), and stop().

Member Function Documentation

bool DBus::Dispatcher::add_connection ( Connection::pointer  connection)
void DBus::Dispatcher::add_read_and_write_watches ( std::vector< struct pollfd > *  fds)
protected

Add all read and write watch FDs to the given vector to watch.

References m_mutex_watches, and m_watches.

Referenced by dispatch_thread_main().

Dispatcher::pointer DBus::Dispatcher::create ( bool  is_running = true)
static
Connection::pointer DBus::Dispatcher::create_connection ( DBusConnection *  cobj = NULL,
bool  is_private = false 
)
Connection::pointer DBus::Dispatcher::create_connection ( BusType  type,
bool  is_private = false 
)
Connection::pointer DBus::Dispatcher::create_connection ( const Connection other)
void DBus::Dispatcher::dispatch_connections ( )
protected
void DBus::Dispatcher::dispatch_thread_main ( )
protectedvirtual
void DBus::Dispatcher::handle_read_and_write_watches ( std::vector< struct pollfd > *  fds)
protected

Handle all of the read and write watches if the given FD needs to be serviced.

References m_mutex_watches, and m_watches_map.

Referenced by dispatch_thread_main().

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

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

Referenced by add_connection().

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

Referenced by add_connection().

void DBus::Dispatcher::on_wakeup_main ( Connection::pointer  conn)
protected

References wakeup_thread().

Referenced by add_connection().

void DBus::Dispatcher::on_watch_toggled ( Watch::pointer  watch)
protected

References wakeup_thread().

Referenced by add_connection().

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

Member Data Documentation

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_connections().

std::thread* DBus::Dispatcher::m_dispatch_thread
protected

Referenced by start(), and stop().

std::vector<int> DBus::Dispatcher::m_exception_fd_set
protected
std::mutex DBus::Dispatcher::m_mutex_exception_fd_set
protected
std::mutex DBus::Dispatcher::m_mutex_watches
protected
bool DBus::Dispatcher::m_running
protected
std::list<Watch::pointer> DBus::Dispatcher::m_watches
protected
std::map<int,Watch::pointer> DBus::Dispatcher::m_watches_map
protected
int DBus::Dispatcher::process_fd[2]
protected

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

Generated on Sun Mar 19 2017 14:54:27 for dbus-cxx by doxygen 1.8.8