On 12/06/2009 03:16 AM, Alexander Larsson wrote: > This change only affects the case where the appliation uses gobject (and > thus initializes it early). If g_type_init is not called then there is > no difference wrt the current behaviour. > I see. This seems like a step in the right direction, but I was hoping that this would be the full auto-initialization that has been talked about off and on in the past (it would make it never necessary to call g_thread_init manually): http://mail.gnome.org/archives/gtk-devel-list/2007-January/msg00005.html http://mail.gnome.org/archives/gtk-devel-list/2008-August/msg00110.html I understand that you don't want to introduce such a change lightly. I guess what I really would like is a way that I can use GLib privately from my library and have it be thread-safe without requiring users of my library have to link against gthread and call g_thread_init. I think it is primarily just GSlice that is the trouble here: I'm only using a few bits of GLib: GList and GHashtable, and they call into GSlice that is not-threadsafe until g_thread_init is called. (I'm currently using GThread a bit, but I can replace that with pthread and use the Win32 pthread implementation for Windows. See http://mail.gnome.org/archives/gtk-devel-list/2006-March/msg00013.html for an old discussion about this in GLib.) Interestingly, before GSlice was implemented, GList and GHashtable and those things were thread safe, since malloc is thread safe, yes? (When I say thread safe here, I'm talking about calling g_hashtable_new from different threads, not manipulating an existing GHashtable simultaneously from multiple threads.) Thanks, Adam
Attachment:
signature.asc
Description: OpenPGP digital signature