[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: thread-safety (was: gtk_timeout_add)
- From: Daniel Burrows <Daniel_Burrows brown edu>
- To: gtk-app-devel-list redhat com
- Subject: Re: thread-safety (was: gtk_timeout_add)
- Date: Fri, 13 Aug 1999 22:10:19 -0400
On Fri, Aug 13, 1999 at 06:03:22PM -0400, Christopher T. Lansdown was heard to say:
> 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
Ah, I see. Would it be possible for the next iteration of GTK+ to do
preprocessor magic along the lines of..
#ifdef _REENTRANT
#define gtk_widget_activate(wid) \
{ gdk_threads_enter(); gtk_widget_activate(wid); gdk_threads_leave(); }
#endif
... or would it be too much trouble and destroy readability of the headers?
Daniel
--
The Disc, being flat, has no real horizon. Any adventurous sailors who get
funny ideas from staring at eggs and oranges too long and set out for the
antipodes soon discovert that the reason that distant ships sometimes look
like they're disappearing over the edge of the world is that they *are*
disappearing over the edge of the world.
-- Terry Pratchett, _The Light Fantastic_
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]