Re: g_thread_init question
- From: Tristan Van Berkom <tvb gnome org>
- To: "Alan M. Evans" <ame1 extratech com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: g_thread_init question
- Date: Wed, 01 Jun 2005 15:25:56 -0400
Alan M. Evans wrote:
Hello all!
The docs on developer.gnome.org state that g_thread_init() will abort if
called twice and suggest the following construct to avoid multiple
calls:
if (!g_thread_supported ()) g_thread_init (NULL);
Has nobody noticed that there's a race condition there?
If I make a class that internally uses threads and mutexes, how do I
protect myself against another class (not necessarily mine) created in
another thread (not necessarily under my control) also calling
g_thread_init() because it is also internally using gthread?
That sounds conceptualy broken, if I instantiate a GObject that
is a GtkWidget, the GtkWidgetClass initializer will not call gtk_init()
for me, so why should an object using the thread system have to call
g_thread_init () ?
Maybe it would be appropriate for the class initializer to do:
if (!g_thread_supported ())
g_critical ("You must initialize the thread subsystem "
"to use MyObjectClass");
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]