[systemd-devel] Using sdbus-cpp
Carlo Wood
carlo at alinoe.com
Fri Feb 26 09:45:07 UTC 2021
Hi,
I am trying to integrate sdbus-cpp into my library
(rather, a collection of git submodules, see
https://github.com/CarloWood/ai-statefultask-testsuite).
A core principle of this project is that ALL threads
are managed by a very sophisticated thread pool; SO
sophisticated in terms of (not!) going to sleep and waking
up (which takes 50 micro seconds each time easily)
that this really is the only place where that may happen.
This way I can also guarantee a one thread-per core
mapping. Furthermore a thread may never block, once
let lose by the thread pool main loop they must run
at full capacity (100% cpu cycles) non-stop until
they return to the thread pool.
All of this isn't really relevant as long as you are
willing to accept this means the following:
sdbus-cpp may 1) never block, 2) not create threads.
Theoretically I only need it to generate the protocol
text and I'd handle the rest (sockets, connections,
timing, threads etc). But it seems that API is not
provided. Instead I have to let the library write and
read that protocol to and from a fd.
I tried the approach of using sd_bus_set_fd, which
seems the most logical approach: sdbus wants to write
to a fd instead of providing call backs with the
protocol text, so I provide it with a fd.
This has led to several problems however; for example,
I had to copy the code that constructs the session
bus address from environment variables because this
is not exposed API (otherwise I can't open my socket).
Several other issues remain (basically all the result
of missing API; for example there is no way to set
sd_bus::is_local).
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?
Thanks in advance,
Carlo Wood
More information about the systemd-devel
mailing list