Re: GObject + signals + threads... i have a question



Tomasz Jankowski wrote:
Hi!

I have a problem and I need to know such thing to solve it:
Let say, that we have a multi thread program with two threads: A and B. Now
in A thread we declare and create an new object based on GObject and connect
FOO signal to it. Later, in B thread we use this object and for we try to
emit FOO signal using 'g_signal_emit' on it. Now the most important thing
for me, in which thread signal FOO will be executed, in thread A or in
thread B?

    Every thread has access to the same shared data, so you can add/remove
signal callbacks at any time - signals are emitted synchronously
(contrary to some people's wild imaginings ;-) ), so for example - when
you call a function that results in an emitted signal... that signal's
callbacks will be run before the function returns (obviously without
changing threads at all).

Based on the same principal, you can be sure that all signal callbacks that
result of gdk events (i.e. all/most widget feedback) will be executed in
the same thread that is running gtk_main().

Cheers,
                      -Tristan



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