GLib Main Loop

  • Event-based applications have many things waiting for something to happen.

  • GLib main loop (g_main_*()) coordinates all of this activity.

  • Functions can be called based on various triggers:

    • During idle moments (priorities against other idle functions can be set).

    • On a scheduled basis (using timeouts)

    • When input arrives or output is ready to be sent (controlled by polling file descriptors).

  • Not all external libraries fit into the GLib main loop structure easily. This can be a hinderance when leveraging existing work.