summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-27 07:18:54 +0200
committerSven Gothel <[email protected]>2010-10-09 03:57:02 +0200
commited254acfa7474877cded7ea14588d0cc8d08ef67 (patch)
tree16d3a9f2c02cc6213cc75d219d9acdc2d3964791 /src/nativewindow/classes
parentecb4673c21281143b394080b7c7ac42ccccd8fc4 (diff)
- Fix GLProcAddressResolver regression: Use GLProcAddressResolver !
- X11GLXDrawableFactory: - Move shared resource creation/destruction into it's own thread - Remove the ATI hack (no XDisplay closing) for every Display, this is only necessary for the shared XDisplay and in case of AWT. - Newt - Display: Only pumpMessages if device is ready. - X11Display: Verify handle not null at DispatchMessage. - Common recursive ToolkitLock implementation, from src/nativewindow/classes/com/jogamp/nativewindow/impl/LockingNativeWindowFactory.java and src/newt/classes/com/jogamp/newt/Window.java, -> com.jogamp.nativewindow.impl.RecursiveToolkitLock - Unique XLockDisplay/XUnlockDisplay call via X11Util to simplify debugging. X11Util: Added debug code for XLockDisplay/XUnlockDisplay. Added fast LongObjectHashMap Added static lib loading and initialization. Removed active and passive list, as well as unused methods, to easy maintenance. Possible since the only 'uncloseable' Display might be the shareable one. - X11Lib: Added static initialization via X11Util Test: junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGears* - Add WindowListener for quit ..
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java
new file mode 100644
index 0000000..06ce543
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java
@@ -0,0 +1,83 @@
+package com.jogamp.nativewindow.impl;
+
+import javax.media.nativewindow.*;
+
+//
+// Reentrance locking toolkit
+//
+public class RecursiveToolkitLock implements ToolkitLock {
+ private Thread owner;
+ private int recursionCount;
+ private Exception lockedStack = null;
+ private static final long timeout = 3000; // maximum wait 3s
+
+ public Exception getLockedStack() {
+ return lockedStack;
+ }
+
+ public Thread getOwner() {
+ return owner;
+ }
+
+ public boolean isOwner() {
+ return isOwner(Thread.currentThread());
+ }
+
+ public synchronized boolean isOwner(Thread thread) {
+ return owner == thread ;
+ }
+
+ public synchronized boolean isLocked() {
+ return null != owner;
+ }
+
+ /** Recursive and blocking lockSurface() implementation */
+ public synchronized void lock() {
+ Thread cur = Thread.currentThread();
+ if (owner == cur) {
+ ++recursionCount;
+ return;
+ }
+
+ long ts = System.currentTimeMillis();
+ while (owner != null && (System.currentTimeMillis()-ts) < timeout) {
+ try {
+ wait(timeout);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ if(owner != null) {
+ lockedStack.printStackTrace();
+ throw new RuntimeException("Waited "+timeout+"ms for: "+owner+" - "+cur);
+ }
+ owner = cur;
+ lockedStack = new Exception("Previously locked by "+owner);
+ }
+
+
+ /** Recursive and unblocking unlockSurface() implementation */
+ public synchronized void unlock() {
+ unlock(null);
+ }
+
+ /** Recursive and unblocking unlockSurface() implementation */
+ public synchronized void unlock(Runnable releaseAfterUnlockBeforeNotify) {
+ Thread cur = Thread.currentThread();
+ if (owner != cur) {
+ lockedStack.printStackTrace();
+ throw new RuntimeException(cur+": Not owner, owner is "+owner);
+ }
+ if (recursionCount > 0) {
+ --recursionCount;
+ return;
+ }
+ owner = null;
+ lockedStack = null;
+ if(null!=releaseAfterUnlockBeforeNotify) {
+ releaseAfterUnlockBeforeNotify.run();
+ }
+ notifyAll();
+ }
+}
+