JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.newt.util.EDTUtil Interface Reference

EDT stands for Event Dispatch Thread. More...

Collaboration diagram for com.jogamp.newt.util.EDTUtil:

Public Member Functions

long getPollPeriod ()
 
void setPollPeriod (long ms)
 
void start () throws IllegalStateException
 Starts the EDT after it's creation or after stopping. More...
 
boolean isCurrentThreadEDT ()
 Returns true if the current thread is the event dispatch thread (EDT). More...
 
boolean isCurrentThreadNEDT ()
 Returns true if the current thread is the internal NEWT event dequeue thread (NEDT). More...
 
boolean isCurrentThreadEDTorNEDT ()
 Returns true if either isCurrentThreadEDT() or isCurrentThreadNEDT() is true, otherwise false. More...
 
boolean isRunning ()
 
boolean invokeStop (boolean wait, Runnable finalTask)
 Append the final task to the EDT task queue, signals EDT to stop. More...
 
boolean invoke (boolean wait, Runnable task)
 Appends task to the EDT task queue if current thread is not EDT, otherwise execute task immediately. More...
 
boolean waitUntilIdle ()
 Wait until the EDT task queue is empty. More...
 
boolean waitUntilStopped ()
 Wait until EDT task is stopped. More...
 

Static Public Attributes

static final long defaultEDTPollPeriod = 10
 

Detailed Description

EDT stands for Event Dispatch Thread.

EDTUtil comprises the functionality of:

  • Periodically issuing an event dispatch command on the EDT.
  • Ability to enqueue tasks, executed on the EDT.
  • Controlling the EDT, ie start and stop in a sane manner.

The EDT pattern is a common tool to comply with todays windowing toolkits, where the common denominator in regards to multithreading is to:

  • Create a Window on one thread
  • Modify the Window within the same thread
  • Handle incoming events from within the same thread

Note: This is not true on MacOSX, where all these actions have to be performed by a unique, so called main thread.

Definition at line 53 of file EDTUtil.java.

Member Function Documentation

◆ getPollPeriod()

long com.jogamp.newt.util.EDTUtil.getPollPeriod ( )
Returns
poll period in milliseconds

◆ invoke()

boolean com.jogamp.newt.util.EDTUtil.invoke ( boolean  wait,
Runnable  task 
)

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
true if task has been executed or queued for later execution, otherwise false
Here is the caller graph for this function:

◆ invokeStop()

boolean com.jogamp.newt.util.EDTUtil.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:

  • 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
true if task has been executed or queued for later execution, otherwise false

◆ isCurrentThreadEDT()

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

◆ isCurrentThreadEDTorNEDT()

boolean com.jogamp.newt.util.EDTUtil.isCurrentThreadEDTorNEDT ( )

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

◆ isCurrentThreadNEDT()

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

◆ isRunning()

boolean com.jogamp.newt.util.EDTUtil.isRunning ( )
Returns
True if EDT is running and not subject to be stopped.
Here is the caller graph for this function:

◆ setPollPeriod()

void com.jogamp.newt.util.EDTUtil.setPollPeriod ( long  ms)
Parameters
mspoll period in milliseconds

◆ start()

void com.jogamp.newt.util.EDTUtil.start ( ) throws IllegalStateException

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.

Exceptions
IllegalStateExceptionif EDT is running and not subject to be stopped, i.e. isRunning() returns true
RuntimeExceptionif EDT could not be started
See also
invokeStop(boolean, java.lang.Runnable)
waitUntilStopped()
Here is the caller graph for this function:

◆ waitUntilIdle()

boolean 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
true if waited for idle, otherwise false, i.e. in case of current thread is EDT or NEDT

◆ waitUntilStopped()

boolean 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
true if stopped, otherwise false, i.e. in case of current thread is EDT or NEDT

Member Data Documentation

◆ defaultEDTPollPeriod

final long com.jogamp.newt.util.EDTUtil.defaultEDTPollPeriod = 10
static

Definition at line 55 of file EDTUtil.java.


The documentation for this interface was generated from the following file: