Re: glib: processing events in multiple threads
- From: richard boaz <ivor boaz gmail com>
- To: gtk-list <gtk-list gnome org>
- Subject: Re: glib: processing events in multiple threads
- Date: Tue, 30 Apr 2013 11:27:30 +0200
and i do it a different way. you say you the main loop is not a part of the main processing of your program, but this really doesn't matter. in this case, you could:
- start a g_main_loop() in a separate thread from the main processing thread, at startup, executing the whole time the program is active
- when any work needs to be done via this loop, use g_idle_add() and friends to execute the necessary function - function will be executed on next main_loop fetch
- you should generally not use g_main_context_iteration(), as you've discovered, you cannot control what happens when multiple things are happening at the same time
this way, since the main loop is running in a separate thread than main(), your synchronous calls that need to execute outside of glib can be invoked from main(), without having to worry about the fact that there is a main_loop() running in a separate thread.
i hurt my brain trying to get my head around your design (no insult intended, really). only meaning to say, that at a design level, when it has to become so convoluted, this can't be the solution.
richard
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]