[systemd-devel] Using sdbus-cpp

Lennart Poettering lennart at poettering.net
Fri Feb 26 13:22:57 UTC 2021


On Fr, 26.02.21 10:45, Carlo Wood (carlo at alinoe.com) wrote:

> Nevertheless-- I'm still facing blocking behavior:
> Following a simple example, I'm using:
>
>     auto reply = concatenatorProxy->callMethod(method);
>
> which ends up calling poll, and block :/.
>
> To make a long story short, what do I have to do to be
> able to use this library if I don't want it to block?

I can't comment on the C++ wrapper, it's not maintained by us. But
sd-bus itself is fully async, all calls are by default async, but for
some there are synchronous wrappers, for convenience. For example, for
calling a method use sd_bus_call_async() if you need things
asynchronously. Use sd_bus_call() if you want a simple synchronous
wrapper for that.

See the the man page sd_bus_call(3) for details.

You can interate sd-bus into arbitrary event loops if you like, or use
the one we provide, via sd-event. Use
sd_bus_get_fd()/sd_bus_get_events()/sd_bus_get_timeout() for
integration to foreign event loops.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list