aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-07-07 03:41:25 +0200
committerSven Gothel <[email protected]>2011-07-07 03:49:33 +0200
commit13802cd232ae5a1f5df91a0cbe63c7565bcd1aaa (patch)
tree8a537bfbab41b1446513b28f22bcdb1d9c00c5b0
parentdaa18e59e03c3e3141e9c4a456eea2fa14fed18c (diff)
Fix SharedResource (SR) Initializationv2.0-rc2-maintenance
- Catch exceptions in SR thread avoiding deadlock in blocking caller thread - Catch NPE on SR queries to return null if appropriate
-rw-r--r--src/jogl/classes/jogamp/opengl/SharedResourceRunner.java73
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java12
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java49
3 files changed, 70 insertions, 64 deletions
diff --git a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java
index 386679992..2c396e265 100644
--- a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java
+++ b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java
@@ -83,43 +83,40 @@ public class SharedResourceRunner implements Runnable {
this.impl = impl;
}
- public SharedResourceRunner.Resource getShared(AbstractGraphicsDevice device) {
- String connection = device.getConnection();
- return impl.mapGet(connection);
- }
-
public SharedResourceRunner.Resource getOrCreateShared(AbstractGraphicsDevice device) {
- String connection = device.getConnection();
- SharedResourceRunner.Resource sr = impl.mapGet(connection);
-
- if (null == sr && !getDeviceTried(connection)) {
- addDeviceTried(connection);
- if (DEBUG) {
- System.err.println("getOrCreateShared() " + connection + ": trying");
- }
- doAndWait(connection, null);
+ SharedResourceRunner.Resource sr = null;
+ if(null != device) {
+ String connection = device.getConnection();
sr = impl.mapGet(connection);
- if (DEBUG) {
- Throwable t = new Throwable("getOrCreateSharedl() " + connection + ": done");
- t.printStackTrace();
+ if (null == sr && !getDeviceTried(connection)) {
+ addDeviceTried(connection);
+ if (DEBUG) {
+ System.err.println("getOrCreateShared() " + connection + ": trying");
+ }
+ doAndWait(connection, null);
+ sr = impl.mapGet(connection);
+ if (DEBUG) {
+ System.err.println("getOrCreateShared() " + connection + ": "+ ( ( null != sr ) ? "success" : "failed" ) );
+ }
}
}
return sr;
}
public SharedResourceRunner.Resource releaseShared(AbstractGraphicsDevice device) {
- String connection = device.getConnection();
- SharedResourceRunner.Resource sr = impl.mapGet(connection);
-
- if (null != sr) {
- removeDeviceTried(connection);
- if (DEBUG) {
- System.err.println("releaseShared() " + connection + ": trying");
- }
- doAndWait(null, connection);
- if (DEBUG) {
- Throwable t = new Throwable("releaseSharedl() " + connection + ": done");
- t.printStackTrace();
+ SharedResourceRunner.Resource sr = null;
+ if(null != device) {
+ String connection = device.getConnection();
+ sr = impl.mapGet(connection);
+ if (null != sr) {
+ removeDeviceTried(connection);
+ if (DEBUG) {
+ System.err.println("releaseShared() " + connection + ": trying");
+ }
+ doAndWait(null, connection);
+ if (DEBUG) {
+ System.err.println("releaseShared() " + connection + ": done");
+ }
}
}
return sr;
@@ -203,7 +200,12 @@ public class SharedResourceRunner implements Runnable {
if (DEBUG) {
System.err.println(threadName + " create Shared for: " + initConnection);
}
- Resource sr = impl.createSharedResource(initConnection);
+ Resource sr = null;
+ try {
+ sr = impl.createSharedResource(initConnection);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
if (null != sr) {
impl.mapPut(initConnection, sr);
}
@@ -212,10 +214,15 @@ public class SharedResourceRunner implements Runnable {
if (DEBUG) {
System.err.println(threadName + " release Shared for: " + releaseConnection);
}
- Resource sr = impl.mapPut(releaseConnection, null);
+ Resource sr = impl.mapGet(releaseConnection);
if (null != sr) {
- impl.releaseSharedResource(sr);
- }
+ try {
+ impl.releaseSharedResource(sr);
+ impl.mapPut(releaseConnection, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
}
initConnection = null;
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 3cbef2569..f1e35c759 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -322,18 +322,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
final static String WGL_ARB_make_current_read = "WGL_ARB_make_current_read";
final static String wglMakeContextCurrent = "wglMakeContextCurrent";
- protected final GLContext getSharedContextImpl(AbstractGraphicsDevice device) {
- SharedResourceRunner.Resource sr = sharedResourceRunner.getShared(device);
- if(null!=sr) {
- return sr.getContext();
- }
- return null;
- }
-
- protected final boolean hasSharedContextImpl(AbstractGraphicsDevice device) {
- return null != getSharedContextImpl(device);
- }
-
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
if(null!=sr) {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 8203a440c..76b1a5043 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -289,27 +289,36 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
public final String getGLXVendorName(AbstractGraphicsDevice device) {
- SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
- if(null!=sr) {
- return ((SharedResource)sr).getGLXVendorName();
+ if(null != device) {
+ SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return ((SharedResource)sr).getGLXVendorName();
+ }
+ return GLXUtil.getVendorName(device.getHandle());
}
- return GLXUtil.getVendorName(device.getHandle());
+ return null;
}
public final boolean isGLXVendorATI(AbstractGraphicsDevice device) {
- SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
- if(null!=sr) {
- return ((SharedResource)sr).isGLXVendorATI();
+ if(null != device) {
+ SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return ((SharedResource)sr).isGLXVendorATI();
+ }
+ return GLXUtil.isVendorATI(device.getHandle());
}
- return GLXUtil.isVendorATI(device.getHandle());
+ return false;
}
public final boolean isGLXVendorNVIDIA(AbstractGraphicsDevice device) {
- SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
- if(null!=sr) {
- return ((SharedResource)sr).isGLXVendorNVIDIA();
+ if(null != device) {
+ SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return ((SharedResource)sr).isGLXVendorNVIDIA();
+ }
+ return GLXUtil.isVendorNVIDIA(device.getHandle());
}
- return GLXUtil.isVendorNVIDIA(device.getHandle());
+ return false;
}
protected final void shutdownInstance() {
@@ -366,13 +375,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean isGLXVersionGreaterEqualOneThree(AbstractGraphicsDevice device) {
- SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
- if(null!=sr) {
- return sr.isGLXVersionGreaterEqualOneThree();
- }
- if( device instanceof X11GraphicsDevice ) {
- VersionNumber v = getGLXVersion( (X11GraphicsDevice) device);
- return ( null != v ) ? v.compareTo(versionOneThree) >= 0 : false ;
+ if(null != device) {
+ SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return sr.isGLXVersionGreaterEqualOneThree();
+ }
+ if( device instanceof X11GraphicsDevice ) {
+ VersionNumber v = getGLXVersion( (X11GraphicsDevice) device);
+ return ( null != v ) ? v.compareTo(versionOneThree) >= 0 : false ;
+ }
}
return false;
}