Re: gdk threads ...

On Mon, May 21, 2012 at 7:36 AM, Michael Meeks <michael meeks suse com> wrote:

       So - yes, the solution of:

       * simply re-write -all- your code to make everything call
         asynchronous / idle handlers on one-of-N glib mainloops

       Has the siren of simplicity for gtk+ maintainers to whom adding a
GDK_THREADS_ENTER / LEAVE pair in a few places seems to be a significant
burden :-)

this is a mis-statement of my point, though i clearly wasn't general enough.

your code must have an event loop abstraction, at some level. if it doesn't then in 2012 there's nothing else to talk about, really.

you might use glib for this (which i would note can be done even when *not* using GTK) or you might use something else.

the only real requirement is that whenever one of the event loops within the application wants to do something with GTK/GDK, it does so by injecting an idle callback into the GTK/GDK event loop, and *not* by calling the GTK/GDK functions directly.

now from my perspective, not using a unified event loop abstraction (such as glib's) all over the place is a headache, but i can see that there are reasons to not do this, certainly for now. but i can't see any fundamental objection to changing the following pseudo-code:

      /* running in some non GDK/GTK thread ... */

      gtk_widget_do_foo (widget, bar, baz);


       struct display_thingy {
              GtkWidget* w;
               int arg1;
               float arg2;

       gboolean show_something_on_screen (struct display_thingy* dt) { gdk_widget_do_foo (dt->w, dt->arg1, dt->arg2); g_free (arg); return FALSE;  }

       /* running in some non GDK/GTK thread */

       struct display_thingy* arg = g_malloc (sizeof (struct display_thingy));
       arg->w = foo;
       arg->arg1 = bar;
       arg->arg2 = baz;
       g_idle_add (show_something_on_screen, arg);

the result is a logical program structure that is pointing in the right direction even its not there yet.

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