Top Description Inners Fields Constructors Methods
jogamp.newt.swt

public Class SWTEDTUtil

extends Object
implements EDTUtil
Class Inheritance
All Implemented Interfaces
com.jogamp.newt.util.EDTUtil
Imports
com.jogamp.nativewindow.NativeWindowException, jogamp.newt.Debug, com.jogamp.common.ExceptionUtils, com.jogamp.common.util.InterruptSource, .InterruptedRuntimeException, .RunnableTask, com.jogamp.newt.util.EDTUtil

Simple EDTUtil implementation utilizing the SWT UI thread of the given Display.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
public static final boolean
private final Runnable
private final Object
private final String
private SWTEDTUtil.NEDT
private static long
private int
private final Display
private final ThreadGroup

Constructor Summary

AccessConstructor and Description
public
SWTEDTUtil(final Display newtDisplay, final Display swtDisplay)

Method Summary

Modifier and TypeMethod and Description
public final Display
public long
public final boolean
invoke(final boolean wait, final Runnable task)

Implements com.jogamp.newt.util.EDTUtil.invoke.

Appends task to the EDT task queue if current thread is not EDT, otherwise execute task immediately.
private final boolean
invokeImpl(boolean wait, final Runnable task, boolean stop)

public final boolean
invokeStop(final boolean wait, final Runnable task)

Implements com.jogamp.newt.util.EDTUtil.invokeStop.

Append the final task to the EDT task queue, signals EDT to stop.
public boolean
isCurrentThreadEDT()

Implements com.jogamp.newt.util.EDTUtil.isCurrentThreadEDT.

Returns true if the current thread is the event dispatch thread (EDT).
public final boolean
public final boolean
isCurrentThreadNEDT()

Implements com.jogamp.newt.util.EDTUtil.isCurrentThreadNEDT.

Returns true if the current thread is the internal NEWT event dequeue thread (NEDT).
public boolean
public void
setPollPeriod(final long
poll period in milliseconds
ms
)

Implements com.jogamp.newt.util.EDTUtil.setPollPeriod.

public final void
start()

Implements com.jogamp.newt.util.EDTUtil.start.

Starts the EDT after it's creation or after stopping.
private final void
public final boolean
waitUntilIdle()

Implements com.jogamp.newt.util.EDTUtil.waitUntilIdle.

Wait until the EDT task queue is empty.
public final boolean
waitUntilStopped()

Implements com.jogamp.newt.util.EDTUtil.waitUntilStopped.

Wait until EDT task is stopped.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
public static final boolean DEBUG
dispatchMessagesback to summary
private final Runnable dispatchMessages
edtLockback to summary
private final Object edtLock
nameback to summary
private final String name
nedtback to summary
private SWTEDTUtil.NEDT nedt
pollPeriodback to summary
private static long pollPeriod
start_iterback to summary
private int start_iter
swtDisplayback to summary
private final Display swtDisplay
threadGroupback to summary
private final ThreadGroup threadGroup

Constructor Detail

SWTEDTUtilback to summary
public SWTEDTUtil(final Display newtDisplay, final Display swtDisplay)

Method Detail

getDisplayback to summary
public final Display getDisplay()
getPollPeriodback to summary
public long getPollPeriod()

Implements com.jogamp.newt.util.EDTUtil.getPollPeriod.

Returns:long

Doc from com.jogamp.newt.util.EDTUtil.getPollPeriod.

poll period in milliseconds

Annotations
@Override
invokeback to summary
public final boolean invoke(final boolean wait, final Runnable task)

Implements com.jogamp.newt.util.EDTUtil.invoke.

Doc from com.jogamp.newt.util.EDTUtil.invoke.

Appends task to the EDT task queue if current thread is not EDT, otherwise execute task immediately.

Wait until execution is finished if wait == true.

Can be issued from within EDT, ie from within an enqueued task.
Returns:boolean

true if task has been executed or queued for later execution, otherwise false

Annotations
@Override
invokeImplback to summary
private final boolean invokeImpl(boolean wait, final Runnable task, boolean stop)
invokeStopback to summary
public final boolean invokeStop(final boolean wait, final Runnable task)

Implements com.jogamp.newt.util.EDTUtil.invokeStop.

Doc from com.jogamp.newt.util.EDTUtil.invokeStop.

Append the final task to the EDT task queue, signals EDT to stop.

If wait is true methods blocks until EDT is stopped.

task maybe null
Due to the nature of this method:

  • All previous queued tasks will be finished.
  • No new tasks are allowed, an Exception is thrown.
  • Can be issued from within EDT, ie from within an enqueued task.
  • start() may follow immediately, ie creating a new EDT

Returns:boolean

true if task has been executed or queued for later execution, otherwise false

Annotations
@Override
isCurrentThreadEDTback to summary
public boolean isCurrentThreadEDT()

Implements com.jogamp.newt.util.EDTUtil.isCurrentThreadEDT.

Doc from com.jogamp.newt.util.EDTUtil.isCurrentThreadEDT.

Returns true if the current thread is the event dispatch thread (EDT).

The EDT is the platform specific thread dispatching toolkit-events and executing toolkit-tasks enqueued via invoke(boolean, Runnable).

Usually it is the same thread as used to dequeue informal NEWTEvents (NEDT), see isCurrentThreadNEDT(), however, this may differ, e.g. SWT and AWT implementation.

Annotations
@Override
isCurrentThreadEDTorNEDTback to summary
public final boolean isCurrentThreadEDTorNEDT()

Implements com.jogamp.newt.util.EDTUtil.isCurrentThreadEDTorNEDT.

Doc from com.jogamp.newt.util.EDTUtil.isCurrentThreadEDTorNEDT.

Returns true if either isCurrentThreadEDT() or isCurrentThreadNEDT() is true, otherwise false.

Annotations
@Override
isCurrentThreadNEDTback to summary
public final boolean isCurrentThreadNEDT()

Implements com.jogamp.newt.util.EDTUtil.isCurrentThreadNEDT.

Doc from com.jogamp.newt.util.EDTUtil.isCurrentThreadNEDT.

Returns true if the current thread is the internal NEWT event dequeue thread (NEDT).

The NEDT is the NEWT thread used to dequeue informal NEWTEvents enqueued internally via DisplayImpl#enqueueEvent(boolean, NEWTEvent).

Usually it is the same thread as the EDT, see isCurrentThreadEDT(), however, this may differ, e.g. SWT and AWT implementation.

Annotations
@Override
isRunningback to summary
public boolean isRunning()

Implements com.jogamp.newt.util.EDTUtil.isRunning.

Returns:boolean

Doc from com.jogamp.newt.util.EDTUtil.isRunning.

True if EDT is running and not subject to be stopped.

Annotations
@Override
setPollPeriodback to summary
public void setPollPeriod(final long ms)

Implements com.jogamp.newt.util.EDTUtil.setPollPeriod.

Parameters
ms:long

Doc from com.jogamp.newt.util.EDTUtil.setPollPeriod.

poll period in milliseconds

Annotations
@Override
startback to summary
public final void start() throws IllegalStateException

Implements com.jogamp.newt.util.EDTUtil.start.

Doc from com.jogamp.newt.util.EDTUtil.start.

Starts the EDT after it's creation or after stopping.

If the EDT is running, it must be stopped first and the caller should wait until it's stopped.

Annotations
@Override
Exceptions
IllegalStateException:
if EDT is running and not subject to be stopped, i.e. isRunning() returns true
startImplback to summary
private final void startImpl()
waitUntilIdleback to summary
public final boolean waitUntilIdle()

Implements com.jogamp.newt.util.EDTUtil.waitUntilIdle.

Doc from com.jogamp.newt.util.EDTUtil.waitUntilIdle.

Wait until the EDT task queue is empty.
The last task may still be in execution when this method returns.

Returns:boolean

true if waited for idle, otherwise false, i.e. in case of current thread is EDT or NEDT

Annotations
@Override
waitUntilStoppedback to summary
public final boolean waitUntilStopped()

Implements com.jogamp.newt.util.EDTUtil.waitUntilStopped.

Doc from com.jogamp.newt.util.EDTUtil.waitUntilStopped.

Wait until EDT task is stopped.
No stop action is performed, invokeStop(boolean, java.lang.Runnable) should be used before.

If caller thread is EDT or NEDT, this call will not block.

Returns:boolean

true if stopped, otherwise false, i.e. in case of current thread is EDT or NEDT

Annotations
@Override
jogamp.newt.swt back to summary

pack-priv Class SWTEDTUtil.NEDT

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
pack-priv volatile boolean
pack-priv Object

Constructor Summary

AccessConstructor and Description
public
NEDT(final ThreadGroup tg, final String name)

Method Summary

Modifier and TypeMethod and Description
public final boolean
public final void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Utilizing locking only on tasks and its execution, not for event dispatching.
public final void
start()

Overrides java.lang.Thread.start.

Schedules this thread to begin execution.
Inherited from com.jogamp.common.util.InterruptSource.Thread:
clearInterruptSourcecreategetInterruptCountergetInterruptSourceinterrupt

Field Detail

isRunningback to summary
pack-priv volatile boolean isRunning
shouldStopback to summary
pack-priv volatile boolean shouldStop
syncback to summary
pack-priv Object sync

Hides com.jogamp.common.util.InterruptSource.Thread.sync.

Constructor Detail

NEDTback to summary
public NEDT(final ThreadGroup tg, final String name)

Method Detail

isRunningback to summary
public final boolean isRunning()
runback to summary
public final void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Utilizing locking only on tasks and its execution, not for event dispatching.

Annotations
@Override
startback to summary
public final void start() throws IllegalThreadStateException

Overrides java.lang.Thread.start.

Doc from java.lang.Thread.start.

Schedules this thread to begin execution. The thread will execute independently of the current thread.

A thread can be started at most once. In particular, a thread can not be restarted after it has terminated.

Annotations
@Override
Exceptions
IllegalThreadStateException:
if the thread was already started