Multiple threads and gtk_main()
- From: Gabriele Greco <gabriele greco darts it>
- To: gtk-app-devel-list gnome org
- Subject: Multiple threads and gtk_main()
- Date: Tue, 10 Jul 2007 17:44:59 +0200
I've a few threads (more than one) doing some work (not accessing GTK
functions), I'd like to have a general way to make them notify their
work to the main loop.
I used the g_idle_add() in the previous context where I had only a
thread with this behaviour, but with two or more threads the
g_idle_add() method of notification is not correct IMHO (what happens if
two threads call g_idle_add() before the call of the first one is
processed by the glib main loop?)
I thought about a mutex solution, something like this:
thread X:
lock idle_mutex
g_idle_add(my_idle_func)
my_idle_func:
unlock idle_mutex
[update the gui]
return FALSE
This way should work but when I use mutexes in context I've not full
control on I always fear unhandled deadlock situations...
I though about using a GAsyncQueue for every thread but in this way the
problem I have is how to notify the main loop that there is something on
a queue, I've not found anything in the documentation... I fear the only
way it's to use a pipe or a socket, or an idle function, but in this
case I will occur again in the locking problem, I hope I'm wrong about
this so I'm asking here :)
--
Bye,
Gabry
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]