Top Inners Fields Constructors Methods
jogamp.newt

public Class DefaultEDTUtil

extends Object
implements EDTUtil
Class Inheritance
All Implemented Interfaces
com.jogamp.newt.util.EDTUtil
Imports
java.util.ArrayList, com.jogamp.nativewindow.NativeWindowException, jogamp.common.util.locks.LockDebugUtil, com.jogamp.common.ExceptionUtils, com.jogamp.common.util.InterruptSource, .InterruptedRuntimeException, .RunnableTask, com.jogamp.common.util.locks.Lock, com.jogamp.newt.util.EDTUtil

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 DefaultEDTUtil.NEDT
private final Object
private final String
private static Runnable
private static long
private int
private static final Object
private static final Object
TASK_ATTACHMENT_TEST_ERROR

Used to provoke an exception on the EDT while waiting / blocking.

private ThreadGroup

Constructor Summary

AccessConstructor and Description
public
DefaultEDTUtil(final ThreadGroup tg, final String name, final Runnable dispatchMessages)

Method Summary

Modifier and TypeMethod and Description
public final 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.
public final boolean
private final boolean
invokeImpl(boolean wait, Runnable task, final boolean stop, final boolean provokeError)

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 final 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 final boolean
public final 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
edtback to summary
private DefaultEDTUtil.NEDT edt
edtLockback to summary
private final Object edtLock
nameback to summary
private final String name
nullTaskback to summary
private static Runnable nullTask
pollPeriodback to summary
private static long pollPeriod
start_iterback to summary
private int start_iter
TASK_ATTACHMENT_STOPback to summary
private static final Object TASK_ATTACHMENT_STOP

Used to implement invokeStop(boolean, Runnable).

TASK_ATTACHMENT_TEST_ERRORback to summary
private static final Object TASK_ATTACHMENT_TEST_ERROR

Used to provoke an exception on the EDT while waiting / blocking. Merely exists to test code.

threadGroupback to summary
private ThreadGroup threadGroup

Constructor Detail

DefaultEDTUtilback to summary
public DefaultEDTUtil(final ThreadGroup tg, final String name, final Runnable dispatchMessages)

Method Detail

getPollPeriodback to summary
public final 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
invokeAndWaitErrorback to summary
public final boolean invokeAndWaitError(final Runnable task)
invokeImplback to summary
private final boolean invokeImpl(boolean wait, Runnable task, final boolean stop, final boolean provokeError)
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 final 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 final 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 final 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 back to summary

pack-priv Class DefaultEDTUtil.NEDT

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
pack-priv volatile boolean
pack-priv final ArrayList<RunnableTask>

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.
private final void
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
tasksback to summary
pack-priv final ArrayList<RunnableTask> tasks

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
validateNoRecursiveLocksHoldback to summary
private final void validateNoRecursiveLocksHold()