the main loop

Thiago Macieira thiago at kde.org
Sun Sep 14 23:26:09 PDT 2008


sfora dim wrote:
>Reading the dbus sources I can see several times that "the main loop"
>is mentioned.
>
>(e.g.: the header of dbus_connection_send says that
>dbus_connection_flush() is not necessary because the msg will be sent
>next time the main loop is run)
>
>What is this main loop and where is it ?

The main loop is part of the application. A GUI application today is 
driven by internal and external events: usually, socket inputs, timers 
and user actions on its GUI. The main event loop is where the application 
keeps looping until it detects that it's time to exit.

>is it the dbus library's main loop (if yes - how come it has a main
>loop ? does it have a thread of execution of itself ?) ?

The library has no event loop. It's up to you to write one.

>Or is it the application's (which is using dbus) main loop ? the one
>that periodically calls dbus_connection_read_write() to check if new
>msgs have arrived ?

Applications wouldn't call dbus_connection_read_write(). They'd use the 
callbacks to handling socket and timer events, then the library calls 
some registered callbacks.

-- 
  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/20080915/ef9808be/attachment-0001.pgp 


More information about the dbus mailing list