Can we use GMainloop at the libdbus based program?

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Jan 21 04:57:34 PST 2015


On 21/01/15 08:09, 최형준 wrote:
> We useully use "dbus_connection_dispatch"  or
> "dbus_connection_setup_with_g_main()"
> funnctions for dbus message processing at the libdbus based codes.
> 
> Are there any ways to use GMainloop for dbus message processing at the
> libdbus based codes?

Yes, and dbus_connection_setup_with_g_main() already does that.
Specifically, it runs all libdbus message processing from the
g_main_context_default() context: so for instance if you use
g_main_loop_new(NULL, ...) and then g_main_loop_run(), libdbus message
processing will occur inside that main loop.

If you can, I recommend using GDBus (part of GIO) instead of libdbus. It
is thread-safe (unlike dbus-glib), knows how to use non-default main
contexts (e.g. for threaded applications), and does not rely on the
deprecated and unmaintained dbus-glib library.

    S



More information about the dbus mailing list