Handles multi-threaded dispatching of one or more connections. More...
#include <dispatcher.h>
Public Types | |
typedef DBusCxxPointer < Dispatcher > | pointer |
typedef DBusCxxPointer< const Dispatcher > | const_pointer |
Public Member Functions | |
Dispatcher (bool is_running=true) | |
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 | |
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::pointer > | m_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::pointer > | m_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 |
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.
calculator_client.cpp, calculator_server.cpp, calculator_watcher.cpp, callee.cpp, callee_2.cpp, callee_dispatched.cpp, callee_object.cpp, callee_object_inherited.cpp, caller_dispatched.cpp, caller_object.cpp, hal_proxy.cpp, signal_emitter_3.cpp, signal_emitter_object.cpp, signal_receiver.cpp, signal_receiver_2.cpp, and signal_receiver_object.cpp.
typedef std::list<Connection::pointer> DBus::Dispatcher::Connections [protected] |
typedef DBusCxxPointer<const Dispatcher> DBus::Dispatcher::const_pointer |
Reimplemented in DBus::Glib::Dispatcher.
typedef DBusCxxPointer<Dispatcher> DBus::Dispatcher::pointer |
Reimplemented in DBus::Glib::Dispatcher.
DBus::Dispatcher::Dispatcher | ( | bool | is_running = true |
) |
Reimplemented in DBus::Glib::Dispatcher.
References m_cond_initiate_processing, m_exception_fd_set, m_mutex_initiate_processing, m_mutex_read_watches, m_mutex_write_watches, m_read_fd_set, m_responsiveness, m_write_fd_set, and start().
Referenced by create().
DBus::Dispatcher::~Dispatcher | ( | ) | [virtual] |
Reimplemented in DBus::Glib::Dispatcher.
References is_running(), m_cond_initiate_processing, m_mutex_initiate_processing, m_mutex_read_watches, m_mutex_write_watches, and stop().
bool DBus::Dispatcher::add_connection | ( | Connection::pointer | connection | ) |
References m_connections, on_add_timeout(), on_add_watch(), on_dispatch_status_changed(), on_remove_timeout(), on_remove_watch(), on_timeout_toggled(), on_wakeup_main(), and on_watch_toggled().
Referenced by create_connection().
void DBus::Dispatcher::build_read_fd_set | ( | ) | [protected] |
References m_enabled_read_fds, m_maximum_read_fd, m_mutex_read_watches, and m_read_fd_set.
void DBus::Dispatcher::build_write_fd_set | ( | ) | [protected] |
References m_enabled_write_fds, m_maximum_write_fd, m_mutex_write_watches, and m_write_fd_set.
Dispatcher::pointer DBus::Dispatcher::create | ( | bool | is_running = true |
) | [static] |
Reimplemented in DBus::Glib::Dispatcher.
References Dispatcher().
Referenced by create_connection().
Connection::pointer DBus::Dispatcher::create_connection | ( | const Connection & | other | ) |
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 | ( | DBusConnection * | cobj = NULL , |
|
bool | is_private = false | |||
) |
References add_connection(), and create().
void DBus::Dispatcher::dispatch_thread_main | ( | ) | [protected, virtual] |
Reimplemented in DBus::Glib::Dispatcher.
References DBUS_CXX_DEBUG, DBus::DISPATCH_COMPLETE, DBus::DISPATCH_DATA_REMAINS, m_cond_initiate_processing, m_connections, m_dispatch_loop_limit, m_initiate_processing, m_mutex_initiate_processing, and m_running.
Referenced by proxy_dispatch_thread_main().
bool DBus::Dispatcher::is_running | ( | ) |
References m_running.
Referenced by DBus::Glib::Dispatcher::~Dispatcher(), and ~Dispatcher().
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] |
References DBUS_CXX_DEBUG, m_enabled_read_fds, m_enabled_write_fds, m_maximum_read_fd, m_maximum_write_fd, m_mutex_read_watches, m_mutex_write_watches, m_read_fd_set, m_read_watches, m_write_fd_set, and m_write_watches.
Referenced by add_connection().
void DBus::Dispatcher::on_dispatch_status_changed | ( | DispatchStatus | status, | |
Connection::pointer | conn | |||
) | [protected] |
References DBUS_CXX_DEBUG, DBus::DISPATCH_DATA_REMAINS, m_cond_initiate_processing, m_initiate_processing, and m_mutex_initiate_processing.
Referenced by add_connection().
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] |
References DBUS_CXX_DEBUG, m_enabled_read_fds, m_enabled_write_fds, m_maximum_read_fd, m_maximum_write_fd, m_mutex_read_watches, m_mutex_write_watches, m_read_fd_set, m_read_watches, m_write_fd_set, and m_write_watches.
Referenced by add_connection().
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] |
References DBUS_CXX_DEBUG, m_cond_initiate_processing, m_initiate_processing, and m_mutex_initiate_processing.
Referenced by add_connection().
bool DBus::Dispatcher::on_watch_toggled | ( | Watch::pointer | watch | ) | [protected] |
References DBUS_CXX_DEBUG, m_enabled_read_fds, m_enabled_write_fds, m_mutex_read_watches, m_mutex_write_watches, m_read_fd_set, and m_write_fd_set.
Referenced by add_connection().
void * DBus::Dispatcher::proxy_dispatch_thread_main | ( | void * | arg | ) | [static, protected] |
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 | ) | [static, protected] |
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 | ( | time_t | sec, | |
suseconds_t | usec | |||
) |
References m_responsiveness.
void DBus::Dispatcher::set_responsiveness | ( | const struct timeval & | r | ) |
References m_responsiveness.
bool DBus::Dispatcher::start | ( | ) |
References m_dispatch_thread, m_running, m_watch_thread, proxy_dispatch_thread_main(), and proxy_watch_thread_main().
Referenced by DBus::Glib::Dispatcher::Dispatcher(), and Dispatcher().
bool DBus::Dispatcher::stop | ( | ) |
References m_cond_initiate_processing, m_dispatch_thread, m_mutex_initiate_processing, m_running, and m_watch_thread.
Referenced by DBus::Glib::Dispatcher::~Dispatcher(), and ~Dispatcher().
void DBus::Dispatcher::watch_thread_main | ( | ) | [protected] |
References m_cond_initiate_processing, m_enabled_read_fds, m_enabled_write_fds, m_initiate_processing, m_maximum_read_fd, m_maximum_write_fd, m_mutex_initiate_processing, m_mutex_read_watches, m_mutex_write_watches, m_read_fd_set, m_read_watches, m_responsiveness, m_running, m_write_fd_set, and m_write_watches.
Referenced by proxy_watch_thread_main().
pthread_cond_t DBus::Dispatcher::m_cond_initiate_processing [protected] |
Connections DBus::Dispatcher::m_connections [protected] |
Referenced by add_connection(), dispatch_thread_main(), and DBus::Glib::Dispatcher::on_glibmm_dispatch().
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] |
std::set<int> DBus::Dispatcher::m_enabled_read_fds [protected] |
Referenced by build_read_fd_set(), on_add_watch(), on_remove_watch(), on_watch_toggled(), and watch_thread_main().
std::set<int> DBus::Dispatcher::m_enabled_write_fds [protected] |
Referenced by build_write_fd_set(), on_add_watch(), on_remove_watch(), on_watch_toggled(), and watch_thread_main().
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] |
Referenced by build_read_fd_set(), on_add_watch(), on_remove_watch(), and watch_thread_main().
int DBus::Dispatcher::m_maximum_write_fd [protected] |
Referenced by build_write_fd_set(), on_add_watch(), on_remove_watch(), and watch_thread_main().
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] |
Referenced by build_read_fd_set(), Dispatcher(), on_add_watch(), on_remove_watch(), on_watch_toggled(), watch_thread_main(), and ~Dispatcher().
pthread_mutex_t DBus::Dispatcher::m_mutex_write_watches [protected] |
Referenced by build_write_fd_set(), Dispatcher(), on_add_watch(), on_remove_watch(), on_watch_toggled(), watch_thread_main(), and ~Dispatcher().
fd_set DBus::Dispatcher::m_read_fd_set [protected] |
Referenced by build_read_fd_set(), Dispatcher(), on_add_watch(), on_remove_watch(), on_watch_toggled(), and watch_thread_main().
std::map<int, Watch::pointer> DBus::Dispatcher::m_read_watches [protected] |
Referenced by on_add_watch(), on_remove_watch(), and watch_thread_main().
struct timeval DBus::Dispatcher::m_responsiveness [read, protected] |
Referenced by Dispatcher(), responsiveness(), set_responsiveness(), and watch_thread_main().
bool DBus::Dispatcher::m_running [protected] |
Referenced by DBus::Glib::Dispatcher::dispatch_thread_main(), dispatch_thread_main(), is_running(), start(), stop(), and watch_thread_main().
pthread_t DBus::Dispatcher::m_watch_thread [protected] |
fd_set DBus::Dispatcher::m_write_fd_set [protected] |
Referenced by build_write_fd_set(), Dispatcher(), on_add_watch(), on_remove_watch(), on_watch_toggled(), and watch_thread_main().
std::map<int, Watch::pointer> DBus::Dispatcher::m_write_watches [protected] |
Referenced by on_add_watch(), on_remove_watch(), and watch_thread_main().