D-Bus threading model D-Bus threading model linux linux

D-Bus threading model


As a protocol, D-Bus doesn't address threading.

D-Bus connections receive message serially. At the protocol level, replies to message are asynchronous: i.e. the sender doesn't have to wait for replies before sending more messages.

While in principle a D-Bus implementation could dispatch messages to service implementations concurrently, I don't know of any that do this.

Typically, a D-Bus implementation (or "binding", if you will) allows the service to decide for each method (or even for each method call) whether to respond to incoming method calls synchronously or asynchronously. The details of this are up to the particular implementation you're using.

If you're responding to method calls asynchronously, your service implementation is responsible for making sure that any state is kept consistent while multiple responses are pending. If you always respond synchronously, then you know you're only dealing with one method call at a time.