[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: thread-safety (was: gtk_timeout_add)
- From: "Christopher T. Lansdown" <lansdoct screech cs alfred edu>
- To: "GTK+ App Developer's Mailing List." <gtk-app-devel-list redhat com>
- Subject: Re: thread-safety (was: gtk_timeout_add)
- Date: Fri, 13 Aug 1999 18:03:22 -0400 (EDT)
Daniel,
While what havoc said about Gtk+ not technically being thread
safe, it's not far from being thread-safe. The thread-safety rules go as
follows:
call g_thread_init() before gtk_main() or any other gtk/gdk/glib
calls.
When using gtk/gdk calls, always surround them with
gdk_threads_enter() and gdk_threads_leave().
That's it. You can now make Gtk/gdk calls from any thread, no
making only one thread do the calls. I've verified that this works, too.
Of course, gdk_threads_enter() and gdk_threads_leave() is a bit of typing
overhead, but it is worth it, believe me. While this is technically not
thread-safe behavior (since thread-safety means that the gtk/gdk calls do
this themslef), it is close enough in practice, I think. :-)
-Chris
--
lansdoct@cs.alfred.edu
"If I had had more time I would have not written you at all." - Pascal
Linux Programs: http://cs.alfred.edu/~lansdoct/linux/
Linux - Get there. Today.
Evil Overlord Quote of the Day:
150.I will provide funding and research to develop tactical and strategic
weapons covering a full range of needs so my choices are not limited to
"hand to hand combat with swords" and "blow up the planet".
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]