aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-03-04 14:42:07 +0100
committerSven Gothel <[email protected]>2020-03-04 14:42:07 +0100
commit36ca7245653b1a0897f2070b9acbe0f0898f5949 (patch)
tree96205bd23f265d347cbbaab09c7f46aa4fe6b9f4 /src/nativewindow/classes
parent854924c72599aab8d8193b9cb2b85a25bd395a2d (diff)
OSX/SWT Testing: Drop using 'com.jogamp.newt.util.MainThread' enforcing default test behavior
SWT and OSX's UI TK have their strict threading policy we require to comply with, e.g. see Bug 1398 lately. It doesn't help using our own MainThread vehicle to move the unit test on the OS main thread, as this removes potential causes of deadlocks - which we intend to find and resolve. This patch removed using MainThread altogether from our ant unit testing recipe as well from our manual test scripts. Unit tests are no more executed on the 'main thread'. SWT tests are patched to comply with SWT's UI threading policy. We also catch violations within NewtCanvasSWT and our SWT GLCanvas to provide same behavior on all platforms.
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
index 5a11ee338..7f4a94c5b 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
@@ -669,7 +669,7 @@ public class SWTAccessor {
final long handle = getHandle(swtControl);
if(null != OS_gtk_class) {
- invoke(true, new Runnable() {
+ invokeOnOSTKThread(true, new Runnable() {
@Override
public void run() {
if(realize) {
@@ -744,7 +744,7 @@ public class SWTAccessor {
public static long newGC(final Control swtControl, final GCData gcData) {
final Object[] o = new Object[1];
- invoke(true, new Runnable() {
+ invokeOnOSTKThread(true, new Runnable() {
@Override
public void run() {
o[0] = ReflectionUtil.callMethod(swtControl, swt_control_internal_new_GC, new Object[] { gcData });
@@ -758,7 +758,7 @@ public class SWTAccessor {
}
public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) {
- invoke(true, new Runnable() {
+ invokeOnOSTKThread(true, new Runnable() {
@Override
public void run() {
if(swt_uses_long_handles) {
@@ -771,7 +771,7 @@ public class SWTAccessor {
}
/**
- * Runs the specified action in an SWT compatible thread, which is:
+ * Runs the specified action in an SWT compatible OS toolkit thread, which is:
* <ul>
* <li>Mac OSX
* <ul>
@@ -786,10 +786,10 @@ public class SWTAccessor {
* @see Platform#AWT_AVAILABLE
* @see Platform#getOSType()
*/
- public static void invoke(final boolean wait, final Runnable runnable) {
+ public static void invokeOnOSTKThread(final boolean blocking, final Runnable runnable) {
if( isOSX ) {
// Use SWT main thread! Only reliable config w/ -XStartOnMainThread !?
- OSXUtil.RunOnMainThread(wait, false, runnable);
+ OSXUtil.RunOnMainThread(blocking, false, runnable);
} else {
runnable.run();
}
@@ -798,20 +798,28 @@ public class SWTAccessor {
/**
* Runs the specified action on the SWT UI thread.
* <p>
- * If <code>display</code> is disposed or the current thread is the SWT UI thread
- * {@link #invoke(boolean, Runnable)} is being used.
- * @see #invoke(boolean, Runnable)
+ * If {@code blocking} is {@code true} implementation uses {@link org.eclipse.swt.widgets.Display#syncExec(Runnable)},
+ * otherwise {@link org.eclipse.swt.widgets.Display#asyncExec(Runnable)}.
+ * <p>
+ * If <code>display</code> is {@code null} or disposed or the current thread is the SWT UI thread
+ * {@link #invokeOnOSTKThread(boolean, Runnable)} is being used.
+ * @see #invokeOnOSTKThread(boolean, Runnable)
*/
- public static void invoke(final org.eclipse.swt.widgets.Display display, final boolean wait, final Runnable runnable) {
- if( display.isDisposed() || Thread.currentThread() == display.getThread() ) {
- invoke(wait, runnable);
- } else if( wait ) {
+ public static void invokeOnSWTThread(final org.eclipse.swt.widgets.Display display, final boolean blocking, final Runnable runnable) {
+ if( null == display || display.isDisposed() || Thread.currentThread() == display.getThread() ) {
+ invokeOnOSTKThread(blocking, runnable);
+ } else if( blocking ) {
display.syncExec(runnable);
} else {
display.asyncExec(runnable);
}
}
+ /** Return true if the current thread is the SWT UI thread, otherwise false. */
+ public static boolean isOnSWTThread(final org.eclipse.swt.widgets.Display display) {
+ return null != display && Thread.currentThread() == display.getThread();
+ }
+
//
// Specific X11 GTK ChildWindow - Using plain X11 native parenting (works well)
//