diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java | 19 |
1 files changed, 14 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 565ec967e..ea78f5209 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextLock.java @@ -50,11 +50,13 @@ import javax.media.opengl.*; be raised. */ public class GLContextLock { + protected static final boolean DEBUG = GLContextImpl.DEBUG; + static class SyncData { boolean failFastMode = true; Thread owner = null; int waiters = 0; - Exception lockedStack = null; + Exception lockedStack = null; // only enabled if DEBUG } private SyncData sdata = new SyncData(); // synchronized (flow/mem) mutable access @@ -66,12 +68,16 @@ 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); + if(DEBUG) { + sdata.lockedStack = new Exception("Error: 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 + + if(null!=sdata.lockedStack) { + sdata.lockedStack.printStackTrace(); + } + throw new GLException("Error: Attempt to make context current on thread " + current + " which is already current on thread " + sdata.owner); } else { try { @@ -85,7 +91,9 @@ public class GLContextLock { } } sdata.owner = current; - sdata.lockedStack = new Exception("Previously made current (2) by "+sdata.owner+", lock: "+this); + if(DEBUG) { + 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); } @@ -139,6 +147,7 @@ public class GLContextLock { } } + /** holding the owners stack trace when lock is acquired and DEBUG is true */ public final Exception getLockedStack() { synchronized(sdata) { return sdata.lockedStack; |