Re: Gnome/Gtk and thread safety
- From: Maciej Stachowiak <mjs eazel com>
- To: Havoc Pennington <hp redhat com>
- Cc: "Ryan C. Gordon" <icculus lokigames com>, gtk-devel-list gnome org
- Subject: Re: Gnome/Gtk and thread safety
- Date: 18 Oct 2000 11:17:15 -0700
Havoc Pennington <hp redhat com> writes:
> Maciej Stachowiak <mjs eazel com> writes:
> > We could take the classical Unix approach to fixing non-threadsafe
> > interfaces:
> >
> > widget = gtk_window_new_r ();
> >
> > :-)
> >
> >
> > Actually, I don't get why the code you posted above with
> > gtk_window_new has a race; how could another thread even have access
> > to the value of `widget' right after you assign it, let alone want to
> > sink or unref it?
> >
>
> Assume it's a global variable, or a variable inside some other object
> inside some other object which is a global variable.
>
> A common case might be this code:
>
> static GtkWidget *dialog = NULL;
> if (dialog == NULL)
> dialog = gtk_dialog_new ();
>
> You have to avoid the race; otherwise you'll get bizarre bugs
> eventually, pretty guaranteed.
>
Oh my goodness, using global variables or function-scope statics
concurrently from multiple threads without locking is not threadsafe?
Have you published a paper on this new discovery yet? :-)
- Maciej
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]