gtk + threads: little ideas for gtk-3.0
- From: Felix Kater <fkater googlemail com>
- To: gtk-devel-list gnome org
- Subject: gtk + threads: little ideas for gtk-3.0
- Date: Tue, 13 Mar 2007 23:53:57 +0100
Hi,
just a note on how the use of gtk could be made easier when it comes to
threads (and about what I've stumbled across several times using gtk):
For complex windows gdk_threads_enter() / leave() is not enough. For
instance when widgets operate on others, using gdk_threads_enter()
twice may cause lockups, so you need recursive locks. And, if you
finally chose to entirely switch to what is recommended generally and
put all real gtk action into one thread you end up in quite a lot of
semaphores or similar to trigger and execute these widget operations.
The approach I took to *generally* surround that is (a) using g_idle_add
for every real gtk action (like renaming labels, updating drawables
etc.) which act as something like a simple fire and forget operation.
And (b) to wrap the GtkWidget into another object which holds the value
(e.g. for spinbuttons) to be requested and set separately from gtk
(which of course needs the widget to be connected to
change/destroy/delete events).
As this is on the one hand quite a lot of work--but on the other as far
as I experienced it is a general and not too compilcated solution, why
shouldn't gtk provide that thread-safety by default. I imaginge gtk to
switch on thread-safety (not only awareness) when gtk_threads_init() is
used.
Thank for your attention
Felix
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]