Re: Threads
- From: Olexiy Avramchenko <olexiy ctech cn ua>
- To: Russell Shaw <rjshaw netspace net au>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Threads
- Date: Wed, 15 Dec 2004 19:01:34 +0200
Russell Shaw wrote:
Ok, in gtkmain.c:
void
gtk_main (void)
{
...
if (g_main_loop_is_running (main_loops->data))
{
GDK_THREADS_LEAVE ();
g_main_loop_run (loop);
GDK_THREADS_ENTER ();
gdk_flush ();
}
...
}
So if g_main_loop_run() runs for the duration of the app, then there
is nothing
guarding gdk calls made by gtk callbacks. So, doesn't this mean that
every gtk
operation in a gtk callback that eventually calls a gdk function,
should be
surrounded by gdk_threads_enter()/leave() ?
GTK register a gtk_main_do_event() function to be called on every event
(see gdk_event_handler_set in "gtk/gtkmain.c"). GDK locks the mutex
before gtk_main_do_event() call (see gdk_event_dispatch in
"gdk/x11/gdk-events-x11.c"). Every gtk callback invoked from main loop
will be automatically protected. You should protect only code in
*timeout* and *idle* callbacks, because they run outside gdk event
dispatching code.
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]