summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java19
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java2
2 files changed, 16 insertions, 5 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java
index 6d0c5d984..565ec967e 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java
@@ -51,9 +51,10 @@ import javax.media.opengl.*;
public class GLContextLock {
static class SyncData {
- Thread owner = null;
boolean failFastMode = true;
+ Thread owner = null;
int waiters = 0;
+ Exception lockedStack = null;
}
private SyncData sdata = new SyncData(); // synchronized (flow/mem) mutable access
@@ -65,9 +66,11 @@ public class GLContextLock {
Thread current = Thread.currentThread();
if (sdata.owner == null) {
sdata.owner = current;
+ sdata.lockedStack = new Exception("Previously made current (1) by "+sdata.owner+", lock: "+this);
} else if (sdata.owner != current) {
while (sdata.owner != null) {
if (sdata.failFastMode) {
+ sdata.lockedStack.printStackTrace();
throw new GLException("Attempt to make context current on thread " + current +
" which is already current on thread " + sdata.owner);
} else {
@@ -82,6 +85,7 @@ public class GLContextLock {
}
}
sdata.owner = current;
+ sdata.lockedStack = new Exception("Previously made current (2) by "+sdata.owner+", lock: "+this);
} else {
throw new GLException("Attempt to make the same context current twice on thread " + current);
}
@@ -94,6 +98,7 @@ public class GLContextLock {
Thread current = Thread.currentThread();
if (sdata.owner == current) {
sdata.owner = null;
+ sdata.lockedStack = null;
// Assuming notify() implementation weaks up the longest waiting thread, to avoid starvation.
// Otherwise we would need to have a Thread queue implemented, using sleep(timeout) and interrupt.
sdata.notify();
@@ -112,8 +117,7 @@ public class GLContextLock {
/** Indicates whether this lock is held by the current thread. */
public final boolean isHeld() {
synchronized(sdata) {
- Thread current = Thread.currentThread();
- return (sdata.owner == current);
+ return (Thread.currentThread() == sdata.owner);
}
}
@@ -131,7 +135,14 @@ public class GLContextLock {
public final boolean hasWaiters() {
synchronized(sdata) {
- return (sdata.waiters != 0);
+ return (0 != sdata.waiters);
+ }
+ }
+
+ public final Exception getLockedStack() {
+ synchronized(sdata) {
+ return sdata.lockedStack;
}
}
+
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
index 9f113f337..e2c217ac0 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
@@ -49,7 +49,7 @@ import java.beans.PropertyChangeListener;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
-import com.jogamp.nativewindow.impl.RecursiveToolkitLock;
+import com.jogamp.common.util.RecursiveToolkitLock;
/** Platform-independent class exposing pbuffer functionality to
applications. This class is not exposed in the public API as it