summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-10-07 05:22:39 +0200
committerSven Gothel <[email protected]>2010-10-07 05:22:39 +0200
commitc8a9c59e4838cd43090378a7ed60544449472801 (patch)
treec17b1b9b8f6aea4a491ef6085be7c9910f057c5c /src/newt
parent018c7e8660dc0af68bd129be9af5094d04d0b431 (diff)
Fix: NativeWindow RecursiveToolkitLock, GLWindow lockSurface/unlockSurface
Fix: NativeWindow RecursiveToolkitLock - Use notify(), instead of notifyAll(), so only one thread is being awakened for the single resource. Otherwise starvation and timeout happen, since the oldest thread might not get waken up (earlier than other threads) within timeout. - Inner class for all synchronized (flow/mem) fields for easier fine grained sync/lock. Fix: GLWindow lockSurface/unlockSurface - Enter locked surface block only if surface lock could be acquired
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java26
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java11
2 files changed, 18 insertions, 19 deletions
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index 0e9114145..72c33f596 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -202,7 +202,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
System.err.println("Window.createNative() START ("+getThreadName()+", "+this+")");
}
if( null != parentWindow &&
- NativeWindow.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) {
+ NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
}
try {
@@ -236,26 +236,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private static long getNativeWindowHandle(NativeWindow nativeWindow) {
long handle = 0;
if(null!=nativeWindow) {
- boolean locked=false;
- try {
- if( NativeWindow.LOCK_SURFACE_NOT_READY < nativeWindow.lockSurface() ) {
- locked=true;
+ boolean wasLocked = false;
+ if( NativeSurface.LOCK_SURFACE_NOT_READY < nativeWindow.lockSurface() ) {
+ wasLocked = true;
+ try {
handle = nativeWindow.getWindowHandle();
if(0==handle) {
throw new NativeWindowException("Parent native window handle is NULL, after succesful locking: "+nativeWindow);
}
- }
- } catch (NativeWindowException nwe) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.getNativeWindowHandle: not successful yet: "+nwe);
- }
- } finally {
- if(locked) {
+ } catch (NativeWindowException nwe) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("Window.getNativeWindowHandle: not successful yet: "+nwe);
+ }
+ } finally {
nativeWindow.unlockSurface();
}
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.getNativeWindowHandle: locked "+locked+", "+nativeWindow);
+ System.err.println("Window.getNativeWindowHandle: locked "+wasLocked+", "+nativeWindow);
}
}
return handle;
@@ -809,7 +807,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
NativeWindow parentWindowLocked = null;
if( null != parentWindow ) {
parentWindowLocked = parentWindow;
- if(NativeWindow.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) {
+ if(NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
}
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index a7104bf1a..d39e0e29b 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -456,11 +456,12 @@ public class GLWindow implements GLAutoDrawable, Window {
if(forceReshape) {
sendReshape = true;
}
- lockSurface();
- try{
- helper.invokeGL(drawable, context, displayAction, initAction);
- } finally {
- unlockSurface();
+ if( NativeSurface.LOCK_SURFACE_NOT_READY < lockSurface() ) {
+ try{
+ helper.invokeGL(drawable, context, displayAction, initAction);
+ } finally {
+ unlockSurface();
+ }
}
}
}