[systemd-devel] systemd-devel Digest, Vol 125, Issue 21
Lennart Poettering
lennart at poettering.net
Wed Sep 9 14:24:56 UTC 2020
On Mi, 09.09.20 10:51, 海阔天空 (858293230 at qq.com) wrote:
> Hi All,
>
>
> Could you help with the question below?
> Does sd_dbus support non-blocking or multi-thread?
sd-bus is threads-aware, but not thread-safe. The idea is to allocate
a separate bus connection for each thread, and not share connections
between threads though.
if you want to receive asynchronous notifications via sd-bus, then you
need to invoke sd_bus_wait() + sd_bus_process() in a loop (possibly
interleaved with other calls), or use an event loop of some form, for
example sd-event.
If you invoke usleep() or similar long-blocking syscalls from a thread
that also is supposed to run your bus connection then of course the
processing of the bus connection cannot take place then.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list