Class EDTUtil
- java.lang.Object
-
- com.inductiveautomation.ignition.client.util.EDTUtil
-
public class EDTUtil extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description EDTUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
coalescingInvokeLater(java.lang.Runnable runnable)
Invokes the given runnable on the EDT.static void
coalescingInvokeLater(java.lang.Runnable runnable, int delay)
static void
invokeAfterFirstDisplayed(java.awt.Component component, java.lang.Runnable task)
Calls a runnable after it is first displayed on the screenstatic void
invokeAfterJoin(java.lang.Runnable runnable, java.lang.Thread thread)
Invokes the runnable on the EDT after waiting for the given thread to finish.static void
invokeLater(java.lang.Runnable runnable, int delay)
Invokes the given runnable on the EDT after the delay.static <T> void
invokeWhenComplete(java.util.concurrent.CompletableFuture<T> future, java.util.function.BiConsumer<? super T,? super java.lang.Throwable> c)
static java.lang.Runnable
memoize(java.lang.Runnable runnable)
Creates a runnable that will run the given runnable throughcoalescingInvokeLater(Runnable)
.
-
-
-
Method Detail
-
invokeLater
public static void invokeLater(java.lang.Runnable runnable, int delay)
Invokes the given runnable on the EDT after the delay.- Parameters:
runnable
- runnable to invokedelay
- (in millis)
-
invokeAfterJoin
public static void invokeAfterJoin(java.lang.Runnable runnable, java.lang.Thread thread)
Invokes the runnable on the EDT after waiting for the given thread to finish.
-
invokeWhenComplete
public static <T> void invokeWhenComplete(java.util.concurrent.CompletableFuture<T> future, java.util.function.BiConsumer<? super T,? super java.lang.Throwable> c)
-
memoize
public static java.lang.Runnable memoize(java.lang.Runnable runnable)
Creates a runnable that will run the given runnable through
coalescingInvokeLater(Runnable)
.This is useful for wrapping up lamdas, which aren't very friendly for sending directly to coalescingInvokeLater because they're never equal to each other, so they don't coalesce.
The way to use this is to create one of these memoized runnables using your lamda, and call .run() on it whenever you need to invoke your lamda in a coalesced way.
-
coalescingInvokeLater
public static void coalescingInvokeLater(java.lang.Runnable runnable)
Invokes the given runnable on the EDT. If multiple runnables are posted during the same event processing using this function, and those runnables are .equals() equivalent, then only one of them will be called.
Careful not to use this with lamdas, like:
EDTUtil.coalescingInvokeLater(this::updateSomething);
because it won't work - each call creates a new lambda that is not equal to the last one, so they won't coalesce.
-
coalescingInvokeLater
public static void coalescingInvokeLater(java.lang.Runnable runnable, int delay)
-
invokeAfterFirstDisplayed
public static void invokeAfterFirstDisplayed(java.awt.Component component, java.lang.Runnable task)
Calls a runnable after it is first displayed on the screen
-
-