Proper use of dbus_connection_send_with_reply & DBusPendingCall

Thiago Macieira thiago at kde.org
Thu Dec 27 16:26:50 PST 2007


David Belser wrote:
>1 - I will be handling the reply in a different thread than the one
>that made the call, this may or may not be that big of an issue
>depending on how and what my app is doing.
>
>2 - There is a brief window where the dispatch thread may receive the
>reply before I've set the callback notify function.

There's a simple solution to both cases: only access the DBusConnection 
from one thread. Your application can be multi-threaded, but you don't 
have to make concurrent accesses to the DBusConnection object.

Since you're talking about a binding, it shouldn't be too difficult to 
wrap those concepts.

However, there is also a drawback: the dispatching thread has to be 
available. Either it's a dedicated thread for that job or it's a thread 
that you guarantee not to block on expensive operations. If it's not a 
dedicated thread, you have to worry about deadlocks as well (dipatching 
thread calls aux thread that tries to access D-Bus).

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20071227/80e51099/attachment.pgp 


More information about the dbus mailing list