Re: Screen updates while long time running subroutine



On 16 Jul 2001 23:21:07 +0000, Eric Smith wrote:
> I'm working on a simulator, and had been trying to run the
> simulation from idle callbacks.  Each idle callback will run the
> simulation for a while then return.
> 
> It just occurred to me to wonder, if things are idle, Should I expect my
> idle callback function be executed repeatedly?  Or does each installed
> idle callback function only get called once per "idle period"?
> 
> Jeroen Benckhuijsen <jfbenck home nl> wrote:
> > See: http://www.gtk.org/faq/#AEN561
> 
> Which describes using a statement like
> 
> 	while (g_main_iteration(FALSE));
> 
> in the midst of functions that do length calculations.
> 
> Am I better off using this method rather than idle callbacks?
> 
> What is the difference between that, and:
> 
> 	while (gtk_events_pending())
> 	  gtk_main_iteration();
> 
> which is recommended in Pennington's book _GTK+/Gnome Application Develoment_?
> 
> Thanks!
> Eric
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
I don't really know the difference between the method recommended by
Havoc, or the method described in the faq. I've used the method from
havoc in my own app. Also this was in the FAQ previously as a solution
to this problem. I don't really know why it changed to this new way.
Maybe it's internally the same???

Don't know if idle callbacks will work beter or worse in this case.
Anyhow, you'll have to return control to glib/gtk ones in a while in
your calculation. I think this is a rather common problem, but the
sollution depends on the situation. In some cases threads are preferred
in other cases the above way. Threads may be a little overkill in some
situations and a source for bugs (because of race conditions and
synchronization). It really makes your code more complex.

Greetz,

--
Jeroen Benckhuijsen

Software Engineer
Phoenix Software




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