public abstract class Invoker extends java.lang.Object implements Disposable
Modifier and Type | Class and Description |
---|---|
static class |
Invoker.Background |
static class |
Invoker.BackgroundThread
Deprecated.
use
Background(Disposable) instead |
static class |
Invoker.EDT
This class is the
Invoker in the Event Dispatch Thread,
which is the only one valid thread for this invoker. |
Disposable.Parent
Modifier and Type | Method and Description |
---|---|
<T> CancellablePromise<T> |
compute(java.util.function.Supplier<? extends T> task)
Computes the specified task immediately if the current thread is valid,
or asynchronously after all pending tasks have been processed.
|
<T> CancellablePromise<T> |
computeLater(java.util.function.Supplier<? extends T> task)
Computes the specified task asynchronously on the valid thread.
|
<T> CancellablePromise<T> |
computeLater(java.util.function.Supplier<? extends T> task,
int delay)
Computes the specified task on the valid thread after the specified delay.
|
void |
dispose()
Usually not invoked directly, see class javadoc.
|
static Invoker |
forBackgroundPoolWithReadAction(Disposable parent) |
static Invoker |
forBackgroundThreadWithoutReadAction(Disposable parent) |
static Invoker |
forBackgroundThreadWithReadAction(Disposable parent) |
static Invoker |
forEventDispatchThread(Disposable parent) |
int |
getTaskCount()
Returns a workload of the task queue.
|
CancellablePromise<?> |
invoke(java.lang.Runnable task)
Invokes the specified task immediately if the current thread is valid,
or asynchronously after all pending tasks have been processed.
|
CancellablePromise<?> |
invokeLater(java.lang.Runnable task)
Invokes the specified task asynchronously on the valid thread.
|
CancellablePromise<?> |
invokeLater(java.lang.Runnable task,
int delay)
Invokes the specified task on the valid thread after the specified delay.
|
boolean |
isValidThread()
Returns
true if the current thread allows to process a task. |
CancellablePromise<?> |
runOrInvokeLater(java.lang.Runnable task)
Deprecated.
use
invoke(Runnable) or compute(Supplier) instead |
java.lang.String |
toString() |
public java.lang.String toString()
toString
in class java.lang.Object
public void dispose()
Disposable
dispose
in interface Disposable
public boolean isValidThread()
true
if the current thread allows to process a task.true
if the current thread is valid, or false
otherwisepublic final <T> CancellablePromise<T> compute(java.util.function.Supplier<? extends T> task)
task
- a task to execute on the valid threadpublic final <T> CancellablePromise<T> computeLater(java.util.function.Supplier<? extends T> task)
task
- a task to execute asynchronously on the valid threadpublic final <T> CancellablePromise<T> computeLater(java.util.function.Supplier<? extends T> task, int delay)
task
- a task to execute asynchronously on the valid threaddelay
- milliseconds for the initial delaypublic final CancellablePromise<?> invoke(java.lang.Runnable task)
task
- a task to execute on the valid threadpublic final CancellablePromise<?> invokeLater(java.lang.Runnable task)
task
- a task to execute asynchronously on the valid threadpublic final CancellablePromise<?> invokeLater(java.lang.Runnable task, int delay)
task
- a task to execute asynchronously on the valid threaddelay
- milliseconds for the initial delay@Deprecated public final CancellablePromise<?> runOrInvokeLater(java.lang.Runnable task)
invoke(Runnable)
or compute(Supplier)
insteadtask
- a task to execute on the valid threadpublic final int getTaskCount()
public static Invoker forEventDispatchThread(Disposable parent)
public static Invoker forBackgroundPoolWithReadAction(Disposable parent)
public static Invoker forBackgroundThreadWithReadAction(Disposable parent)
public static Invoker forBackgroundThreadWithoutReadAction(Disposable parent)