Running dbus_connection_read_write_dispatch in a separate thread

Simon McVittie smcv at collabora.com
Thu Jun 18 16:51:14 UTC 2020


On Thu, 18 Jun 2020 at 19:29:25 +0300, Alexandru Sorodoc wrote:
> How do I get a file descriptor?

Use dbus_connection_set_watch_functions() to ask the connection to tell
you about its file descriptor(s) and the event(s) it wants you to poll for.
You will likely also need dbus_connection_set_timeout_functions(),
dbus_connection_set_wakeup_main_function() and
dbus_connection_set_dispatch_status_function().

https://gitlab.freedesktop.org/dbus/dbus-glib/-/blob/dbus-gmain/dbus-gmain.c
is a complete example of everything that's needed, although using GLib's
main loop abstraction rather than doing its own polling.

I hope you saw the documentation's warning that "If you use this low-level
API directly, you're signing up for some pain".

Good luck,
    smcv


More information about the dbus mailing list