Async DBusMessage reads using the C API

Havoc Pennington hp at redhat.com
Fri Nov 4 20:55:33 PST 2005


On Fri, 2005-11-04 at 17:49 +0000, Matthew Johnson wrote:
> I have a patch that does it like that with a separate function. I agree
> though, thats sensible. I have a question about the current
> implementation of read_write_dispatch though, it seems to do the
> dispatch before  the read_write iteration, shouldn't it be the other way
> round---otherwise things are read off the wire and not dispatched until
> the next call to read_write_dispatch()? Also, it appears to not do a
> read_write iteration if there is data to dispatch, so it either
> read_writes, or dispatches---rather than both, as I would expect.
> 
> I'd expect it to work more like:
> 
>     do_iteration(timeout);
>     if (dispatch && has_data) dispatch();

It's intended to make exactly one "unit of progress," whether that's a
read/write or a dispatch of exactly one message.
dbus_connection_dispatch() also dispatches only one message, not the
whole queue. The idea is that this gives you the most flexibility by
returning control to the application as often as possible, while
otherwise there would be an indefinite amount of processing happening on
each call. For what you're doing you probably want:

 dbus_connection_read_write(connection, 0);
 while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS)
    ;

Havoc




More information about the dbus mailing list