Re: glib main loop concept



On 10/3/07, Christian Buennig <masala web de> wrote:
> I want to add IO watches to the default context in a library. Apps using
> the library may decide to start a main loop themselves (in the default
> context) or to let the library do this. Of course they could tell the
> library somehow if there already is a running main loop in the default
> context, but it would be nice if the library could detect this itself.

I'm not sure this is a good idea. I think a library has no place
starting main loops, unless they are completely isolated from the
(possible) application main loop. You are likely to cause confusion
and distress. A main loop should be started from an application's
main() and nowhere else (except for nested calls I guess).

I recommend you just add your IO watches to the default context (or
maybe have a parameter for context-to-add-the-watch-to, in the way
that glib does) and say in your documentation that the library user is
responsible for calling g_main_loop_run() or whatever.

(not that I'm a great expert on this)

John



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]