Re: DBUS - how to handle muliple bus-message in parallel

Simon McVittie <smcv-ZGY8ohtN/[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <[email protected]>
On Tue, 21 Aug 2018 at 10:08:34 +1200, Lawrence D'Oliveiro wrote:
> To avoid holding up
> the dispatching of subsequent messages in the meantime, you need to do
> your actual message processing on a separate thread.

Either that, or use an event loop (for example the GLib main loop)
to defer the actual work to happen later, and send the reply when the
actual work has been done. For example, this is very common in programs
that do some mixture of D-Bus, networking and GUIs.

Using a good event loop implementation that has a concept of thread
contexts, for example
<https://developer.gnome.org/programming-guidelines/stable/main-contexts.html.en>
or <https://doc.qt.io/qt-5/thread-basics.html>,
will also make it a lot easier to pass tasks between threads, so this
is win/win really.

Also consider using a higher-level implementation of D-Bus, for example
GLib's GDBus or Qt's QtDBus, instead of the reference implementation
libdbus. More specialized implementations like GDBus can assume that
you are using "their" event loop, which makes them simpler to use and
easier to get right. libdbus suffers from being too generic: it has
all the necessary parts to be connected to a third-party event loop,
but does not make it easy or obvious, because it supports all event
loops equally well (or to put it another way, equally badly).

    smcv
_______________________________________________
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.