Re: g_main_loop

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

 



On Tue, 2008-07-15 at 19:15 +0800, HASWANI HARISH-VCKR47 wrote:
> Hi All,
>  
> I am a beginner to gtk APIs. 
> My query is : 
> - In Thread T1 I am calling g_main_loop()
> - In Thread T2 I am emitting a signal through
> g_signal_emit_by_name(G_OBJECT, signal-name);
>  
> I saw that signal handler is running in Thread2 context. I want that
> it should run in Thread 1 context. How I can achieve this?

best to think of some other model. gobject signals do not (trivially)
cross thread boundaries. the most widely adopted approach is to use
g_idle_add() to (thread-safely) add an idle callback that emits the
signal from the correct (g_main_loop()) thread:

gboolean foobar (gpointer foo) { 
      g_signal_emit_by_name (foo, signal-name); 
      return FALSE;
}

in thread T2:

   ...
   g_idle_add (foobar, G_OBJECT);
   ...

something like that, anyway.


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux