How to avoid client side polling?

Thiago Macieira thiago at kde.org
Sun Jul 29 13:57:56 PDT 2007


Fan Wu wrote:
>>Yes, there is. Have it select as well on a pipe, onto which you can
>> write to make the loop wake up. We use that technique in Qt.
>
>Could you please show me a link to the Qt code that does this?

You can find one example here:
http://websvn.kde.org/trunk/qt-copy/src/corelib/kernel/qeventdispatcher_unix.cpp?view=markup

and another here:
http://websvn.kde.org/trunk/qt-copy/src/corelib/kernel/qeventdispatcher_glib.cpp?view=markup

Take a look at the wakeUp functions and search for "thread_pipe" to see 
where it's used.

>> You want to have a select-based event loop in your application and
>> just plug the DBusConnection socket descriptor into it. Like I
>> described in the previous email.
>
>Are you suggesting writing a mainloop which polls the file descriptor
>of DBusConnection, as well as a pipe specifically added to wake up the
>select sleep?

I am suggesting you integrate the DBusConnection file descriptor into your 
application's existing mainloop. You must have one already to obtain 
events from the system, for timers and for sockets.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20070729/7108803d/attachment.pgp 


More information about the dbus mailing list