A ThreadDispatcher is responsible for executing method calls and signals on objects in the given thread.
If you are using the standard DBus::Dispatcher class, you can either run all method calls in the dispatcher thread, and create a ThreadDispatcher in the main thread with a main loop.
If you're using Qt, link with dbus-cxx-qt and use the QtThreadDispatcher class.
If you're using GLib, link with dbus-cxx-glib and use the GLibThreadDispatcher class.
Note that all methods in this class are called from the dispatcher thread.
virtual void DBus::ThreadDispatcher::add_message |
( |
std::shared_ptr< Object > |
object, |
|
|
std::shared_ptr< const CallMessage > |
message |
|
) |
| |
|
pure virtual |
When a new message comes in that needs to be processed, this method is called with the object that the method needs to go to, and the message to send to this object.
Generally, this method should push the object/message onto some sort of mutex-locked queue and then wakeup this thread. The thread will then lock the mutex, pop an element off of the queue, and direct the message to the given object via the handle_message method
- Parameters
-
object | The object to send the message to |
message | The message to send to the object |
virtual void DBus::ThreadDispatcher::add_signal |
( |
std::shared_ptr< const SignalMessage > |
message | ) |
|
|
pure virtual |
When a new signal message comes in that needs to be processed, this method is called with the SignalMessage that must be emitted from this thread.
Generally, this method should push the SignalMesage onto some sort of mutex-locked queue and then wakeup this thread. This thread will then lock the mutex, pop an element off of the queue, and loop through all of the signal proxys (added via add_signal_proxy) and calling the SignalProxyBase::handle_signal method.
- Parameters
-
message | The message to be emitted |