GTK usage within threads
- From: mikecorn <mikecorn t-online de>
- To: gtk-devel-list gnome org
- Subject: GTK usage within threads
- Date: Fri, 14 Jul 2006 09:58:34 -0700 (PDT)
I have spent lots of time looking at various informal and unofficial
documents and messages pertaining to using GDK and GTK in threads. I have
tried to follow the advise received, but I am not sure I have it right.
My threaded applications work OK and are reliable, but I sometimes
experience a performance problem: slow window updates: things hang dead for
a few seconds and then explode with activity. Sometimes I can trigger this
by generating unrelated mouse events or clicking scroll bars, etc. The
symptoms seem to be saying that the main loop is not running as frequently
as it needs and window updates are pending in buffers and not getting
Here is what I am doing, in summary. I hope someone with more expertise can
take a few minutes to tell me if I am doing someting wrong.
build main window, menus, toolbar, text_view window, etc.
main-functions() using GTK:
nothing special is done, with the following exception:
if a main function must block itself due to a conflict
with a thread, the following is done to keep the main loop
running (and avoid locking-up menus and window updates):
while (gtk_events_pending()) gtk_main_iteration();
usleep(1000) // sleep 1 millisec.
(I think the problem is here: if I eliminate the usleep()
and make a hard loop instead, window updates progress
at high speed) (not a good solution for obvious reasons)
thread-functions() using GTK:
gtk calls for dialogs or to update main window
View this message in context: http://www.nabble.com/GTK-usage-within-threads-tf1944290.html#a5330269
Sent from the Gtk+ - Dev - General forum at Nabble.com.
] [Thread Prev