Re: loops and contexts



Hi,

If single iterations of the simulation processing are short then you may
prefer scheduling them with g_idle_add() and g_timeout_add() families
of functions. No need to mess with multiple main loops and contexts. See more
here:
https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html
Multiple main loops are nested rather than parallel so they probably will
not be helpful for simulation processing. If you really need parallel processing
then you need multiple threads. If you decide to choose multiple threads then
you can create main loops in the secondary threads or ignore GTK+ totally
and implement your own loop or use another toolkit. There is nothing that
forces you to use GLib main loop in all threads or disables you from using
other toolkits.

Regards,

RafaƂ


8.05.2016 21:23 Krzysztof <kj limes com pl> wrote:

 Having said this, if you have a simple simulation program written based on
GTK+ it's reasonable to engage one main loop for windowing and the other for
simulation processing which results are shown in a window. Am I right? But
what about context? Should it be the one main or is it better to create new
one?

 Regards
 Krzysztof J.

 On 05/08/2016 03:36 PM, Paul Davis wrote:

     > >      Also, worth differentiating between 1 main loop per thread +
     > > multiple threads, and multiple recursive main loops per thread.
     Modal dialogs involve a recursive main loop, but it runs in the same
thread as the normal main loop does (since it runs "inside" the "real" main
loop).
     An application like Ardour runs N main loops in N threads, with each
thread dealing with a different type of event source. We do not multiplex
the event sources into the normal main loop, because we do not want the GUI
behaviour potentially interferred with by the demands of these other UI
control systems. Not many applications require this design.

     On Sat, May 7, 2016 at 6:10 PM, Ben Iofel <iofelben gmail com
mailto:iofelben gmail com > wrote:
      > > >       Dialogs, for example, have their own main loop.
      Generally, though, you will have one main loop (gtk's loop) even for
multiple windows in your app.

      On Fri, May 6, 2016 at 4:11 PM, Krzysztof < mailto:kj limes com pl
kj limes com pl mailto:kj limes com pl > wrote:
       > > > > Is there a reason to have more than one MainContext or more
       > > > > than one MainLoop? Or is it more appropriate to add event
       > > > > handlers to one application main loop (I mean
       > > > > GtkApplication)?

       --
       Regards
       Krzysztof J.

       _______________________________________________
       gtk-list mailing list
       gtk-list gnome org mailto:gtk-list gnome org
       https://mail.gnome.org/mailman/listinfo/gtk-list
      > > > 
      _______________________________________________
      gtk-list mailing list
      gtk-list gnome org mailto:gtk-list gnome org
      https://mail.gnome.org/mailman/listinfo/gtk-list
     > > 
 > 

 

_______________________________________________
 gtk-list mailing list
 gtk-list gnome org
 https://mail.gnome.org/mailman/listinfo/gtk-list




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