From e4745f57283bbbd3fcafa7739dcbdce190d0cec5 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 18 May 2007 07:15:35 +0000 Subject: [PATCH] Linux: Removed GCJ workaround since current GCJ versions support re-entrant AWT locking --- src/java/org/lwjgl/opengl/LinuxDisplay.java | 50 +++++---------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 0f2ca29a..ae368695 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -67,15 +67,6 @@ final class LinuxDisplay implements DisplayImplementation { private static final int XRANDR = 10; private static final int XF86VIDMODE = 11; private static final int NONE = 12; - - /** Keep track on the current awt lock owner to avoid - * depending on JAWT locking to be re-entrant (This is a - * problem with GCJ). JAWT locking is not that well specified - * anyway so it is probably best to avoid assuming too much - * about it. - */ - private static Thread current_awt_lock_owner; - private static int awt_lock_count; /** Current X11 Display pointer */ private static long display; @@ -212,41 +203,20 @@ final class LinuxDisplay implements DisplayImplementation { * Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to * do just that. */ - static synchronized void lockAWT() { - Thread this_thread = Thread.currentThread(); - while (current_awt_lock_owner != null && current_awt_lock_owner != this_thread) { - try { - LinuxDisplay.class.wait(); - } catch (InterruptedException e) { - LWJGLUtil.log("Interrupted while waiting for awt lock: " + e); - } + static void lockAWT() { + try { + nLockAWT(); + } catch (LWJGLException e) { + LWJGLUtil.log("Caught exception while locking AWT: " + e); } - if (awt_lock_count == 0) { - current_awt_lock_owner = this_thread; - try { - nLockAWT(); - } catch (LWJGLException e) { - LWJGLUtil.log("Caught exception while locking AWT: " + e); - } - } - awt_lock_count++; } private static native void nLockAWT() throws LWJGLException; - static synchronized void unlockAWT() { - if (awt_lock_count <= 0) - throw new IllegalStateException("AWT not locked!"); - if (Thread.currentThread() != current_awt_lock_owner) - throw new IllegalStateException("AWT already locked by " + current_awt_lock_owner); - awt_lock_count--; - if (awt_lock_count == 0) { - try { - nUnlockAWT(); - } catch (LWJGLException e) { - LWJGLUtil.log("Caught exception while unlocking AWT: " + e); - } - current_awt_lock_owner = null; - LinuxDisplay.class.notify(); + static void unlockAWT() { + try { + nUnlockAWT(); + } catch (LWJGLException e) { + LWJGLUtil.log("Caught exception while unlocking AWT: " + e); } } private static native void nUnlockAWT() throws LWJGLException;