aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLWorkerThread.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-20 09:02:53 +0100
committerSven Gothel <[email protected]>2012-03-20 09:02:53 +0100
commitb7c5a58f3fd44f87ff3a79410f72260efce7a552 (patch)
treed071492fbdca8be12e74aab571687152a207712c /src/jogl/classes/jogamp/opengl/GLWorkerThread.java
parentb823e8a0e18ec0b357d62af468a14162a9fb4948 (diff)
Cleanup: Use getThreadName() and validateCurrent() to remove redundancy and to add thread-name info; GLWorkerThread: Use ArrayList and generics.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLWorkerThread.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLWorkerThread.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java
index ac9655fbb..e717ec64c 100644
--- a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java
+++ b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java
@@ -40,8 +40,10 @@
package jogamp.opengl;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-import javax.media.opengl.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.media.opengl.GLContext;
/** Singleton thread upon which all OpenGL work is performed by
default. Unfortunately many vendors' OpenGL drivers are not really
@@ -64,7 +66,7 @@ public class GLWorkerThread {
// The Runnable to execute immediately on the worker thread
private static volatile Runnable work;
// Queue of Runnables to be asynchronously invoked
- private static List queue = new LinkedList();
+ private static List<Runnable> queue = new ArrayList<Runnable>();
/** Should only be called by Threading class if creation of the
GLWorkerThread was requested via the opengl.1thread system
@@ -141,7 +143,7 @@ public class GLWorkerThread {
*/
} else {
- throw new RuntimeException("Should not start GLWorkerThread twice");
+ throw new RuntimeException(getThreadName()+": Should not start GLWorkerThread twice");
}
}
}
@@ -150,7 +152,7 @@ public class GLWorkerThread {
public static void invokeAndWait(Runnable runnable)
throws InvocationTargetException, InterruptedException {
if (!started) {
- throw new RuntimeException("May not invokeAndWait on worker thread without starting it first");
+ throw new RuntimeException(getThreadName()+": May not invokeAndWait on worker thread without starting it first");
}
Object lockTemp = lock;
@@ -177,7 +179,7 @@ public class GLWorkerThread {
public static void invokeLater(Runnable runnable) {
if (!started) {
- throw new RuntimeException("May not invokeLater on worker thread without starting it first");
+ throw new RuntimeException(getThreadName()+": May not invokeLater on worker thread without starting it first");
}
Object lockTemp = lock;
@@ -208,6 +210,10 @@ public class GLWorkerThread {
return (Thread.currentThread() == thread);
}
+ protected static String getThreadName() {
+ return Thread.currentThread().getName();
+ }
+
static class WorkerRunnable implements Runnable {
public void run() {
// Notify starting thread that we're ready
@@ -252,10 +258,10 @@ public class GLWorkerThread {
while (!queue.isEmpty()) {
try {
- Runnable curAsync = (Runnable) queue.remove(0);
+ Runnable curAsync = queue.remove(0);
curAsync.run();
} catch (Throwable t) {
- System.err.println("Exception occurred on JOGL OpenGL worker thread:");
+ System.err.println(getThreadName()+": Exception occurred on JOGL OpenGL worker thread:");
t.printStackTrace();
}
}