classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: RFC: portable native sync initialization


From: Thomas Fitzsimmons
Subject: [cp-patches] Patch: RFC: portable native sync initialization
Date: Wed, 27 Apr 2005 21:59:50 -0400

Hi,

We don't use the portable native sync code in libgcj so I'm posting this
patch here for discussion.  When the AWT parts of OpenOffice.org were
initialized, we were seeing a GThread assertion failure:

GThread-ERROR **: GThread system may only be initialized once.

See: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=154215

It turned out that we needed to check g_thread_supported () before
initializing the threading system.  This works fine in libgcj because it
uses the native threading implementation, just like GTK.

Unfortunately, GThread doesn't allow overriding the threading
implementation after it has already been initialized.  This means that
running the AWT under OpenOffice.org on a portable native sync-using JVM
will likely be problematic.  I'm not sure how to work around it.  Worse,
Owen says that overriding the threading system at all, even at
initialization-time, will be deprecated in a future release of GLib.

Does this patch look acceptable to people?  All it does is issue a
warning when portable native sync must be disabled.

Tom

2005-04-27  Thomas Fitzsimmons  <address@hidden>

        * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
        (init_glib_threads): Check if threading system is already
        initialized.

Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c,v
retrieving revision 1.5
diff -u -u -r1.5 gnu_java_awt_peer_gtk_GtkToolkit.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c     22 Feb 2005 06:13:03 
-0000      1.5
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c     28 Apr 2005 01:57:30 
-0000
@@ -275,10 +275,22 @@
     }
   
   (*env)->GetJavaVM( env, &the_vm );
-  if (portableNativeSync)
-    g_thread_init ( &portable_native_sync_jni_functions );
+  if (!g_thread_supported ())
+    {
+      if (portableNativeSync)
+        g_thread_init ( &portable_native_sync_jni_functions );
+      else
+        g_thread_init ( NULL );
+    }
   else
-    g_thread_init ( NULL );
+    {
+      /* Warn if portable native sync is desired but the threading
+         system is already initialized.  In that case we can't
+         override the threading implementation with our portable
+         native sync functions. */
+      if (portableNativeSync)
+        g_printerr ("peer warning: portable native sync disabled.\n");
+    }
 
   /* Debugging progress message; uncomment if needed: */
   /*   printf("called gthread init\n"); */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]