Re: g_main_loop
- From: Paul Davis <paul linuxaudiosystems com>
- To: HASWANI HARISH-VCKR47 <harish haswani motorola com>
- Cc: gtk-list gnome org
- Subject: Re: g_main_loop
- Date: Tue, 15 Jul 2008 07:36:27 -0400
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]