From: Theodore A. R. <ta...@gm...> - 2010-12-06 22:08:22
|
On Mon, Dec 6, 2010 at 2:06 PM, Vince Laviano <vla...@go...> wrote: > Hi Ted, > On Mon, Dec 6, 2010 at 11:59 AM, Jason Glasgow <jgl...@go...> wrote: >> >> see main() for how we attach the dbus-c++ dispatcher to the glib main >> loop. >> >> http://git.chromium.org/gitweb/?p=cashew.git;a=blob;f=src/main.cc;h=d7f64fe5f37b99e91d7eb2ef9e4566f01833e521;hb=HEAD#l102 >> >> -Jason > > dbus-c++ provides several flavors of dispatcher. > The vanilla one (DBus::BusDispatcher) does implement its own event loop, > entered by DBus::BusDispatcher::enter and exited by > DBus::BusDispatcher::leave. > There is a separate dispatcher for glib integration: > DBus::Glib::BusDispatcher. When using the glib dispatcher, you still need > to attach it, but, since it's using the glib main loop, the enter and leave > routines are no-ops. You instead create a glib main loop and enter and leave > the loop using the usual glib calls: g_main_loop_run and g_main_loop_quit. > See the cashew link that Jason provided for an example of how to use the > glib dispatcher. > The add_timeout, rem_timeout, add_watch, and rem_watch methods on the > default dispatcher seem promising at first glance, but the conversation > quoted below suggests that you've already tried them with no luck. > Andreas says in the thread below: >> Are you sure the C backend of DBus provides such a feature? Could you name >> a function? > The C backend for D-Bus is meant to allow integration of D-Bus events into > an existing external event loop. So, it provides the ability for code > implementing this event loop to provide a callback function for libdbus to > call when libdbus wants to add a timeout that will be managed by this > external event loop (and similarly for watches on fds that libdbus want the > external event loop to manage). However, one would expect that the external > event loop will... um... be an event loop, meaning that its public API > allows timeouts and watches to be created, managed, and removed by arbitrary > clients, not just by libdbus through the dbus binding. IMO, if the default > dispatcher purports to be a real event loop (and it's not clear that it > does, since it's intentionally very simple), it should allow timeouts and > watches to be managed. It should do this just because it's an event loop, > not because it's part of a D-Bus binding. That's exactly the (false) assumption I was making about BusDispatcher. > Ted: An alternate approach would be to ignore the default dispatcher, look > at how DBus::Glib::BusDispatcher is implemented, and follow the same model > to implement DBus::EventLibThatTedPrefersInsteadOfGlib::BusDispatcher. > Vince Will have a look at that and see where it takes me. Thanks for the help guys. I think that will get me on the right track. Ted Roth |