aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java')
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java
index 42e1c9be5..2203d744a 100644
--- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java
+++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java
@@ -27,8 +27,6 @@
*/
package com.jogamp.newt.swt;
-import java.awt.EventQueue;
-
import javax.media.nativewindow.NativeWindowException;
import jogamp.newt.Debug;
@@ -83,7 +81,7 @@ public class SWTEDTUtil implements EDTUtil {
synchronized(edtLock) {
waitUntilStopped();
if(DEBUG) {
- System.err.println(Thread.currentThread()+": EDT reset - edt: "+nedt);
+ System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt);
}
this.nedt = new NewtEventDispatchThread(threadGroup, name);
this.nedt.setDaemon(true); // don't stop JVM from shutdown ..
@@ -92,13 +90,13 @@ public class SWTEDTUtil implements EDTUtil {
private final void startImpl() {
if(nedt.isAlive()) {
- throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt);
+ throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt);
}
start_iter++;
nedt.setName(name+start_iter);
nedt.shouldStop = false;
if(DEBUG) {
- System.err.println(Thread.currentThread()+": EDT START - edt: "+nedt);
+ System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt);
// Thread.dumpStack();
}
nedt.start();
@@ -136,9 +134,6 @@ public class SWTEDTUtil implements EDTUtil {
}
private void invokeImpl(boolean wait, Runnable task, boolean stop) {
- if(task == null) {
- throw new RuntimeException("Null Runnable");
- }
Throwable throwable = null;
RunnableTask rTask = null;
Object rTaskLock = new Object();
@@ -147,7 +142,7 @@ public class SWTEDTUtil implements EDTUtil {
if( nedt.shouldStop ) {
// drop task ..
if(DEBUG) {
- System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt);
+ System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt);
Thread.dumpStack();
}
return;
@@ -157,20 +152,21 @@ public class SWTEDTUtil implements EDTUtil {
if(stop) {
nedt.shouldStop = true;
if(DEBUG) {
- System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt);
+ System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt);
// Thread.dumpStack();
}
+ } else if( !nedt.isRunning() ) {
+ // start if should not stop && not started yet
+ startImpl();
}
- if( isCurrentThreadEDT() ) {
+ if( null == task ) {
+ wait = false;
+ } else if( isCurrentThreadEDT() ) {
task.run();
wait = false; // running in same thread (EDT) -> no wait
} else if( swtDisplay.isDisposed() ) {
wait = false; // drop task, SWT disposed
} else {
- // start if should not stop && not started yet
- if( !stop && !nedt.isRunning() ) {
- startImpl();
- }
rTask = new RunnableTask(task,
wait ? rTaskLock : null,
true /* always catch and report Exceptions, don't disturb EDT */);
@@ -255,7 +251,7 @@ public class SWTEDTUtil implements EDTUtil {
@Override
final public void run() {
if(DEBUG) {
- System.err.println(getName()+": EDT run() START "+ getName());
+ System.err.println(getName()+": SWT-EDT run() START "+ getName());
}
RuntimeException error = null;
try {
@@ -289,11 +285,11 @@ public class SWTEDTUtil implements EDTUtil {
if(t instanceof RuntimeException) {
error = (RuntimeException) t;
} else {
- error = new RuntimeException("Within EDT", t);
+ error = new RuntimeException("Within SWT-EDT", t);
}
} finally {
if(DEBUG) {
- System.err.println(getName()+": EDT run() END "+ getName()+", "+error);
+ System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error);
}
synchronized(edtLock) {
isRunning = !shouldStop;
@@ -302,7 +298,7 @@ public class SWTEDTUtil implements EDTUtil {
}
}
if(DEBUG) {
- System.err.println(getName()+": EDT run() EXIT "+ getName()+", exception: "+error);
+ System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error);
}
if(null!=error) {
throw error;