Re: Gnome/Gtk and thread safety
- From: Havoc Pennington <hp redhat com>
- To: Maciej Stachowiak <mjs eazel com>
- Cc: "Ryan C. Gordon" <icculus lokigames com>, gtk-devel-list gnome org
- Subject: Re: Gnome/Gtk and thread safety
- Date: 18 Oct 2000 10:23:05 -0400
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.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]