Top Description Inners Fields Constructors Methods
com.sun.glass.ui

public final Class InvokeLaterDispatcher

extends Thread
Class Inheritance
Imports
java.util.concurrent.*

A dispatcher for Application.invokeLater() that submits deferred runnables to the native system one by one. A native system may, by default, execute all submitted runnables before actually leaving a nested event loop. However, there is an assumption that a runnable that calls the Application.leaveNestedEventLoop() method must be the last runnable executed in the current inner event loop. The next runnable that might have already been submitted by client code must be invoked in the context of the outer event loop. To satisfy this requirement, the runnables must be submitted to the native system one by one. This allows for a fine grained control over the execution of the deferred tasks when it comes to entering/leaving nested event loops despite native system limitations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
public static interface
InvokeLaterDispatcher.InvokeLaterSubmitter

An InvokeLaterDispatcher client implements this interface to allow the dispatcher to submit runnables to the native system.

Field Summary

Modifier and TypeField and Description
private final BlockingDeque<Runnable>
private final InvokeLaterDispatcher.InvokeLaterSubmitter
private volatile boolean
private final Object
private boolean
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
invokeLater(Runnable command)

Schedules execution of a runnable on the event thread.

public void
notifyEnteringNestedEventLoop()

Notifies that a nested event loop is going to be entered.

public void
notifyLeavingNestedEventLoop()

Notifies that the application is leaving a nested event loop.

public void
notifyLeftNestedEventLoop()

Notifies that the application has left a nested event loop.

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

dequeback to summary
private final BlockingDeque<Runnable> deque
invokeLaterSubmitterback to summary
private final InvokeLaterDispatcher.InvokeLaterSubmitter invokeLaterSubmitter
leavingNestedEventLoopback to summary
private volatile boolean leavingNestedEventLoop
LOCKback to summary
private final Object LOCK
nestedEventLoopEnteredback to summary
private boolean nestedEventLoopEntered

Constructor Detail

InvokeLaterDispatcherback to summary
public InvokeLaterDispatcher(InvokeLaterDispatcher.InvokeLaterSubmitter invokeLaterSubmitter)

Method Detail

invokeAndWaitback to summary
public void invokeAndWait(Runnable runnable)
invokeLaterback to summary
public void invokeLater(Runnable command)

Schedules execution of a runnable on the event thread.

See Also
Application#invokeLater(Runnable)
notifyEnteringNestedEventLoopback to summary
public void notifyEnteringNestedEventLoop()

Notifies that a nested event loop is going to be entered. An InvokeLaterDispatcher client is responsible for calling this method just before the enterNestedEventLoop() is dispatched to the native system for actually starting the nested loop.

notifyLeavingNestedEventLoopback to summary
public void notifyLeavingNestedEventLoop()

Notifies that the application is leaving a nested event loop.

notifyLeftNestedEventLoopback to summary
public void notifyLeftNestedEventLoop()

Notifies that the application has left a nested event loop.

runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override
com.sun.glass.ui back to summary

private Class InvokeLaterDispatcher.Future

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private boolean
private final Runnable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
isDone()

Tells whether the runnable has finished execution.

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

doneback to summary
private boolean done
runnableback to summary
private final Runnable runnable

Constructor Detail

Futureback to summary
public Future(Runnable r)

Method Detail

isDoneback to summary
public boolean isDone()

Tells whether the runnable has finished execution. This method must be called under the LOCK lock.

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
com.sun.glass.ui back to summary

public Interface InvokeLaterDispatcher.InvokeLaterSubmitter

Known Direct Implementers
com.sun.glass.ui.gtk.GtkApplication, com.sun.glass.ui.mac.MacApplication, com.sun.glass.ui.win.WinApplication

An InvokeLaterDispatcher client implements this interface to allow the dispatcher to submit runnables to the native system.

Method Summary

Modifier and TypeMethod and Description
public void
submitForLaterInvocation(Runnable r)

Submits the runnable to the native system for later execution and returns immediately.

Method Detail

submitForLaterInvocationback to summary
public void submitForLaterInvocation(Runnable r)

Submits the runnable to the native system for later execution and returns immediately.