How to avoid client side polling?

Havoc Pennington hp at
Sat Jul 28 07:38:36 PDT 2007


Fan Wu wrote:
> I'm thinking about using DBUS for our software product which covers
> hand-held devices. A major concern we have is about polling on the
> client side. Polling frequently drains battery, while polling less
> frequently renders the system irresponsive. Note that our processes
> interacting with DBUS could be dual-roled: they could be
> service-provider and service-consumer at the same time.

I don't understand what you mean, maybe go into more detail - 
libdbus/dbus-daemon do not do polling in the sense of periodically 
checking for anything. dbus does use poll(), but that should not drain 
any battery since it will only wake up when something happens.

With libdbus, you have several choices for setting up your app:
  - use threads and have the threads block on the DBusConnection
  - don't use threads and just block the whole app
  - use a main loop like the one in GLib or a hand-rolled equivalent,
    which will poll() or select() on both the dbus file descriptors
    and your own file descriptors, waking up when something happens
    on one of them

None of these should wake up unless something happens on the descriptors.


More information about the dbus mailing list