Re: Integrating a DBus listener with libevent framework

Simon McVittie <simon.mcvittie-ZGY8ohtN/[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <[email protected]>
On Tue, 23 Aug 2016 at 16:31:31 -0600, Philip Prindeville wrote:
> Most of the examples I've looked at for DBus were based on a main loop that
> DBus would consume messages and invoke its handler.
> 
> In this case, the daemon is single-threaded but event-driven (via libevent)
> since none of the handling of the events ever requires any sort of blocking.

I replied to <https://bugs.freedesktop.org/show_bug.cgi?id=99002>, but
replying here too for completeness.

You would need to write a glue layer that calls
dbus_connection_set_dispatch_status_function(),
dbus_connection_set_watch_functions(), etc., similar to
https://cgit.freedesktop.org/dbus/dbus/tree/test/test-utils.c, but uses
libevent instead of the internal DBusLoop.

There are various examples of people doing this:

* the simple (non-thread-safe) internal main-loop in dbus/dbus-loop.[ch]
  and dbus/dbus-socket-set*

* the multiple main-loop integration layers in Avahi

* the GLib main-loop integration layer in dbus-glib

* the Qt main-loop integration layer in QtDBus

* the Enlightenment main-loop integration layer in
  https://git.enlightenment.org/legacy/bindings/python/python-e_dbus.git/

As you can infer from those, these main-loop integration layers
are usually out-of-tree, and there is enough public API to write one.

I am not going to merge a libevent integration layer into the dbus
core source tree unless I can be confident that someone will maintain
it forever (which seems unlikely). I'm keen to keep dbus/libdbus to
what the reference implementation needs, and no more. However, if someone
who likes libevent releases a third-party libevent integration layer,
I'd be happy to link to it from documentation.

I should warn you that trying to follow a "simplest possible" example is
potentially counter-productive: real, production-ready integration with a
main loop is going to have to do more or less everything that the GLib and
Qt ones do, except obviously using libevent instead of GLib or Qt.

Regards,
    S
_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.