com.jogamp.newt.swt
Class SWTEDTUtil

java.lang.Object
  extended by com.jogamp.newt.swt.SWTEDTUtil
All Implemented Interfaces:
EDTUtil

public class SWTEDTUtil
extends Object
implements EDTUtil

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


Field Summary
static boolean DEBUG
           
 
Fields inherited from interface com.jogamp.newt.util.EDTUtil
defaultEDTPollPeriod
 
Constructor Summary
SWTEDTUtil(Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay)
           
 
Method Summary
 org.eclipse.swt.widgets.Display getDisplay()
           
 long getPollPeriod()
           
 void invoke(boolean wait, Runnable task)
          Shall start the thread if not running.
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(Runnable task)
          Append the final task to the EDT task queue, signals EDT to stop and wait until stopped.
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. EDTUtil.reset() may follow immediately, ie creating a new EDT
 boolean isCurrentThreadEDT()
          Returns true if the current thread is the event dispatch thread (EDT).
 boolean isCurrentThreadEDTorNEDT()
          Returns true if either EDTUtil.isCurrentThreadEDT() or EDTUtil.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, EDTUtil.invokeStop(java.lang.Runnable) should be used before.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Constructor Detail

SWTEDTUtil

public SWTEDTUtil(Display newtDisplay,
                  org.eclipse.swt.widgets.Display swtDisplay)
Method Detail

getDisplay

public final org.eclipse.swt.widgets.Display getDisplay()

getPollPeriod

public long getPollPeriod()
Specified by:
getPollPeriod in interface EDTUtil
Returns:
poll period in milliseconds

setPollPeriod

public void setPollPeriod(long ms)
Specified by:
setPollPeriod in interface EDTUtil
Parameters:
ms - poll period in milliseconds

reset

public void reset()
Description copied from interface: EDTUtil
Create a new EDT. One should invoke reset()
after invokeStop(..) in case another start via invoke(..) is expected.

Specified by:
reset in interface EDTUtil
See Also:
EDTUtil.invoke(boolean, java.lang.Runnable), EDTUtil.invokeStop(java.lang.Runnable)

isCurrentThreadEDT

public boolean isCurrentThreadEDT()
Description copied from interface: EDTUtil
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 EDTUtil.invoke(boolean, Runnable).

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

Specified by:
isCurrentThreadEDT in interface EDTUtil

isCurrentThreadNEDT

public final boolean isCurrentThreadNEDT()
Description copied from interface: EDTUtil
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 EDTUtil.isCurrentThreadEDT(), however, this may differ, e.g. SWT and AWT implementation.

Specified by:
isCurrentThreadNEDT in interface EDTUtil

isCurrentThreadEDTorNEDT

public final boolean isCurrentThreadEDTorNEDT()
Description copied from interface: EDTUtil
Returns true if either EDTUtil.isCurrentThreadEDT() or EDTUtil.isCurrentThreadNEDT() is true, otherwise false.

Specified by:
isCurrentThreadEDTorNEDT in interface EDTUtil

isRunning

public boolean isRunning()
Specified by:
isRunning in interface EDTUtil
Returns:
True if EDT is running

invokeStop

public final void invokeStop(Runnable task)
Description copied from interface: EDTUtil
Append the final task to the EDT task queue, signals EDT to stop and wait until stopped.
Due to the nature of this method:

Specified by:
invokeStop in interface EDTUtil

invoke

public final void invoke(boolean wait,
                         Runnable task)
Description copied from interface: EDTUtil
Shall start the thread if not running.
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.

Specified by:
invoke in interface EDTUtil

waitUntilIdle

public final void waitUntilIdle()
Description copied from interface: EDTUtil
Wait until the EDT task queue is empty.
The last task may still be in execution when this method returns.

Specified by:
waitUntilIdle in interface EDTUtil

waitUntilStopped

public final void waitUntilStopped()
Description copied from interface: EDTUtil
Wait until EDT task is stopped.
No stop action is performed, EDTUtil.invokeStop(java.lang.Runnable) should be used before.

Specified by:
waitUntilStopped in interface EDTUtil


Copyright 2010 JogAmp Community.