<div dir="ltr"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Mon, Mar 20, 2017 at 7:40 PM Stanislav Angelovič <<a href="mailto:angelovic.s@gmail.com" class="gmail_msg" target="_blank">angelovic.s@gmail.com</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Hi Jan,<br class="gmail_msg"><br class="gmail_msg"></div>thanks for quick response. Instead
of sd_bus_process(), we could perhaps use sd_bus_flush() after creating
the connection, as that one actually processes the requests until the
connection changes state to 'running'. I tried this and it helped.<br class="gmail_msg"><br class="gmail_msg"></div>Regarding
polling, I understand, but I fear this way we could get race condition
on the connection instance, since we'd have a thread doing the polling
and processing in a loop on the connection, and some other thread (say
handling the UI, or an external system event, or incoming DBus call from
another connection or whatever else) issuing a DBus call on the same
connection. I think the connection instance is not thread-safe, as once I
experienced such data race related problems. Maybe there is another way
of doing that? One that comes to my mind is having just one single
thread handling the connection and communication through it, but then it
would have to poll on other fd's as well, to be able to communicate
with other threads, for example to get DBus call request from the UI
thread and perform it on the connection. This involves asynchronous
programming paradigm for quite a simple thing, IMHO. What do you think?<br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thank you,<br class="gmail_msg"><br class="gmail_msg"></div>Stanislav.<br class="gmail_msg"></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">Yes, sd-bus was designed with asynchronous programming in mind. It prefers the sd-event event loop, but you can also integrate it into another event loop. The blocking calls all loop internally.<br><br>Your programming language and/or framework might have a preferred DBus implementation already. For example, if you have a GLib/GTK event loop, I would recommend using GIO (GDBus) instead of sd-bus. Similarly, Qt has QDBus.<br class="gmail_msg"></div></div></div></div>