the main loop

Thiago Macieira thiago at kde.org
Mon Sep 15 23:03:30 PDT 2008


sfora dim wrote:
>> This will work fine as long as your program never does anything except
>> receive dbus messages. If it does anything else, then it will block
>> doing the something else when it should be getting dbus messages, or
>> vice versa. The main loop is a solution to the problem that you can
>> only block in one place at a time.
>
>And if I create a dedicated thread just for this main loop, and let my
>program do anything it wants in its other threads, is it ok ?

Depends on your usage.

If you use a dbus_connection_read_write and stay there forever, you'll 
handle incoming calls, but you still won't handle outgoing messages 
properly.

If you only handle incoming (signals and method calls) with no outgoing or 
very little of it (say, only message replies), then a thread would do.

Otherwise, even a thread would require the five functions I listed.

-- 
  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/20080916/c5b47469/attachment.pgp 


More information about the dbus mailing list