using the wakeup_main_function together with dispatch_status_function
jimharvy at gmail.com
Thu Sep 25 21:43:51 PDT 2008
2008/9/26 Havoc Pennington <hp at pobox.com>
> On Thu, Sep 25, 2008 at 4:02 AM, jim harvey <jimharvy at gmail.com> wrote:
> > i've currently removed the use of both functions (set_dispatch_status and
> > set_wakeup_main) and i'm using the
> > my_wakeup_main() function (which i've written as you said) to wake up the
> > main loop in case a new timeout/watch is toggled/added.
> > i use this setup and dispatch in the mainloop while DATA_REMAINS.
> > in this use case, is there need for any of the notifications (dispatch
> > status change or wakeup main)?
> I would not expect that a watch is guaranteed to be toggled or
> added/removed in all cases that there may now be stuff to dispatch,
> for example the main socket read watch is never toggled or removed
> afaik until the connection is closed.
> iirc dispatch status function was added because in some cases messages
> could appear in the incoming queue even though dbus_watch_handle()
> hadn't been called. Originally you were supposed to just always
> dispatch after handling a watch. I don't remember what the cases are.
> One example might be a timeout expiring resulting in a synthetic error
> message created on client side.
> 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.
for now my program is working fine (as far as i can tell) without making use
of these 2 callbacks (wakeup_main, distpatch_status).
i'm worried about the successive wakeups the mainloop will have to do, since
these callbacks are called on every incoming message (i havent checked
concerning the sending of a message from another thread - i think a more
elegant solution would be to use an internal function like:
Now the DBusWatches + watch_add/watch_toggle handle incoming messages wakeup
and i manually handle outgoing messages wakeup.
is there still reason to implement the dispatch functions?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the dbus