com.jogamp.newt.util
Interface EDTUtil


public interface EDTUtil

EDT stands for Event Dispatch Thread.

EDTUtil comprises the functionality of:

The EDT pattern is a common tool to comply with todays windowing toolkits, where the common denominator in regards to multithreading is to: Note: This is not true on MacOSX, where all these actions have to be performed by a unique, so called main thread.


Field Summary
static long defaultEDTPollPeriod
           
 
Method Summary
 long getPollPeriod()
           
 void invoke(boolean wait, Runnable task)
          Shall start the thread if not running, task maybe null for this purpose.
Append task to the EDT task queue.
Wait until execution is finished if wait == true.
Can be issued from within EDT, ie from within an enqueued task.
 void invokeStop(boolean wait, Runnable finalTask)
          Append the final task to the EDT task queue, signals EDT to stop.
 boolean isCurrentThreadEDT()
          Returns true if the current thread is the event dispatch thread (EDT).
 boolean isCurrentThreadEDTorNEDT()
          Returns true if either isCurrentThreadEDT() or isCurrentThreadNEDT() is true, otherwise false.
 boolean isCurrentThreadNEDT()
          Returns true if the current thread is the internal NEWT event dequeue thread (NEDT).
 boolean isRunning()
           
 void reset()
          Create a new EDT.
 void setPollPeriod(long ms)
           
 void waitUntilIdle()
          Wait until the EDT task queue is empty.
The last task may still be in execution when this method returns.
 void waitUntilStopped()
          Wait until EDT task is stopped.
No stop action is performed, invokeStop(boolean, java.lang.Runnable) should be used before.
 

Field Detail

defaultEDTPollPeriod

static final long defaultEDTPollPeriod
See Also:
Constant Field Values
Method Detail

getPollPeriod

long getPollPeriod()
Returns:
poll period in milliseconds

setPollPeriod

void setPollPeriod(long ms)
Parameters:
ms - poll period in milliseconds

reset

void reset()
Create a new EDT. One should invoke reset()
after invokeStop(..) in case another start via invoke(..) is expected.

See Also:
invoke(boolean, java.lang.Runnable), invokeStop(boolean, java.lang.Runnable)

isCurrentThreadEDT

boolean 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.


isCurrentThreadNEDT

boolean 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.


isCurrentThreadEDTorNEDT

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


isRunning

boolean isRunning()
Returns:
True if EDT is running

invokeStop

void invokeStop(boolean wait,
                Runnable finalTask)
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:


invoke

void invoke(boolean wait,
            Runnable task)
Shall start the thread if not running, task maybe null for this purpose.
Append task to the EDT task queue.
Wait until execution is finished if wait == true.
Can be issued from within EDT, ie from within an enqueued task.

Throws:
RuntimeException - in case EDT is stopped and not reset()

waitUntilIdle

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


waitUntilStopped

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



Copyright 2010 JogAmp Community.