using the wakeup_main_function together with dispatch_status_function

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Sep 25 15:14:32 PDT 2008


2008/9/25 Havoc Pennington <hp at pobox.com>:

> An example given in the reference docs for wakeup main is that if a
> message is queued for writing but can't be written immediately, the
> main loop has to be kicked awake to add the write fd to its poll(). In
> this case the watch probably does get toggled.
>
> The API contract is certainly that you should implement all of these
> callbacks, to know for sure on what you can get away with outside of
> the contract, you'd have to carefully review the source and see what
> the current situation is, then hope that situation does not change.

I don't understand the sense of
dbus_connection_set_wakeup_main_function. It assumes too much about
the implementation of the main loop, and for me it seems unnecessary
at all. The documentation says:

"This function is responsible for waking up the main loop (if its
sleeping in another thread) when some some change has happened to the
connection that the mainloop needs to reconsider (e.g. a message has
been queued for writing)."

What exactly should the main loop reconsider in response to the
callback installed by this function? If libdbus needs to do some
internal processing of messages, before trying to send them through a
socket, then this does not involve the main loop; libdbus can do the
processing immediately instead of calling the callback. If writing to
the socket is involved and the socket is not ready yet, then the watch
toggle callback is used. The implementation seems to use this callback
when a message is received, but this triggers the dispatch status
changed callback if the program might not be aware that it should
process messages.

So I ignore dbus_connection_set_wakeup_main_function.

-- 
Marcin Kowalczyk
qrczak at knm.org.pl
http://qrnik.knm.org.pl/~qrczak/


More information about the dbus mailing list