Raw libdbus dispatching
pcjc2 at cam.ac.uk
Tue Oct 24 06:53:05 PDT 2006
I've had some success using libdbus directly (I can't use glib, as the
code I'm writing has to plug into Lesstif and potentially others, as
well as GTK)
Thanks for all the help received so far, I'd not have what I do working
Working from the glib bindings as an example of how to integrate
dispatching with a mainloop, I have a few remaining questions.
Lesstif only supports file IO watches which are Read, Write and
Exception. (HUP is not listed). I'm not sure how to map the dbus request
flags onto Lesstif. Do I need to manually re-poll the file-descriptor
inside my Lesstif callback to check for HUP?
The glib bindings use a custom GSource to dispatch at most one message
per mainloop iteration if there are messages pending. Lesstif doesn't
have a comparible source mechanism. It has Idle work functions (which I
don't want to use, as it will spin CPU time). It has a "block_hook",
which looks useful.. it can call your callback before it blocks in the
mainloop's poll or select function. I could also add a timeout to fire
periodically, but that doesn't seem like a clean solution.
Does dispatching a single message before the mainloop blocks ensure that
we won't get locked up waiting for IO?
Are there any other ways to alleviate the need for a dispatch call in
the mainloop? I don't want to block in the DBus code either though!
Electrical Engineering Division,
University of Cambridge,
9, JJ Thomson Avenue,
Tel: +44 (0)7729 980173
More information about the dbus