aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-02-21 08:20:42 +0000
committerKenneth Russel <[email protected]>2006-02-21 08:20:42 +0000
commit6b3eb7ba25d3ef0123f2f6f1987237e3596b6399 (patch)
treed84e3ccc060d54fc777f27032cc67310c7801ba2
parentc9faf1391d8ab972fb0f1b231c33a5bf02be5051 (diff)
Added exception propagation from GLWorkerThread
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@626 232f8b59-042b-4e1e-8c03-345bb8c30851
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/GLWorkerThread.java24
-rwxr-xr-xsrc/classes/javax/media/opengl/Threading.java8
2 files changed, 23 insertions, 9 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLWorkerThread.java b/src/classes/com/sun/opengl/impl/GLWorkerThread.java
index 7c1d7413b..52ada9bac 100755
--- a/src/classes/com/sun/opengl/impl/GLWorkerThread.java
+++ b/src/classes/com/sun/opengl/impl/GLWorkerThread.java
@@ -39,6 +39,8 @@
package com.sun.opengl.impl;
+import java.lang.reflect.InvocationTargetException;
+
/** Singleton thread upon which all OpenGL work is performed by
default. Unfortunately many vendors' OpenGL drivers are not really
thread-safe and stability is much improved by performing OpenGL
@@ -55,6 +57,7 @@ public class GLWorkerThread {
private static volatile Thread thread;
private static Object lock;
private static volatile boolean shouldTerminate;
+ private static volatile Throwable exception;
// The Runnable to execute on the worker thread -- no need for a
// queue since we don't have an invokeLater() primitive
@@ -85,7 +88,8 @@ public class GLWorkerThread {
}
}
- public static void invokeAndWait(Runnable runnable) {
+ public static void invokeAndWait(Runnable runnable)
+ throws InvocationTargetException, InterruptedException {
if (!started) {
throw new RuntimeException("May not invokeAndWait on worker thread without starting it first");
}
@@ -103,10 +107,9 @@ public class GLWorkerThread {
work = runnable;
lock.notifyAll();
- try {
- lock.wait();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
+ lock.wait();
+ if (exception != null) {
+ throw new InvocationTargetException(exception);
}
}
}
@@ -145,9 +148,14 @@ public class GLWorkerThread {
return;
}
- work.run();
- work = null;
- lock.notifyAll();
+ try {
+ work.run();
+ } catch (Throwable t) {
+ exception = t;
+ } finally {
+ work = null;
+ lock.notifyAll();
+ }
}
}
}
diff --git a/src/classes/javax/media/opengl/Threading.java b/src/classes/javax/media/opengl/Threading.java
index 2f1aa4fb7..7aa57def5 100755
--- a/src/classes/javax/media/opengl/Threading.java
+++ b/src/classes/javax/media/opengl/Threading.java
@@ -250,7 +250,13 @@ public class Threading {
}
}
}
- GLWorkerThread.invokeAndWait(r);
+ try {
+ GLWorkerThread.invokeAndWait(r);
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (InterruptedException e) {
+ throw new GLException(e);
+ }
break;
default: