Linux: Removed GCJ workaround since current GCJ versions support re-entrant AWT locking

This commit is contained in:
Elias Naur 2007-05-18 07:15:35 +00:00
parent fc759e6192
commit e4745f5728
1 changed files with 10 additions and 40 deletions

View File

@ -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;