| Modifier and Type | Field and Description |
|---|---|
protected A[] |
args |
protected R |
result |
protected Function<R,A> |
runnable |
attachment, catchExceptions, exceptionOut, execThread, isExecuted, isFlushed, runnableException, sourceStack, syncObject, tCreated, tExecuted, tStarted| Constructor and Description |
|---|
FunctionTask(Function<R,A> runnable,
Object syncObject,
boolean catchExceptions,
PrintStream exceptionOut)
Create a RunnableTask object w/ synchronization,
ie.
|
| Modifier and Type | Method and Description |
|---|---|
R |
eval(A... args)
Implementation may compute variable
args list
and returns a result. |
R |
getResult()
Retrieves the cached result of
run()
and is cleared within this method. |
Function<R,A> |
getRunnable()
Return the user action
|
static <U,V> U |
invoke(boolean waitUntilDone,
Function<U,V> func,
V... args)
Deprecated.
Simply invoke
Function.eval(Object...) |
static <U,V> FunctionTask<U,V> |
invokeOnNewThread(ThreadGroup tg,
String threadName,
boolean waitUntilDone,
Function<U,V> func,
V... args)
Invokes
func on a new InterruptSource.Thread,
see InterruptSource.Thread#Thread(ThreadGroup, Runnable, String) for details. |
void |
run() |
void |
setArgs(A... args)
Sets the arguments for
run(). |
flush, getAttachment, getDurationInExec, getDurationInQueue, getDurationTotal, getExceptionOutIntro, getExecutionThread, getSyncObject, getThrowable, getTimestampAfterExec, getTimestampBeforeExec, getTimestampCreate, hasWaiter, isExecuted, isFlushed, isInQueue, printSourceTrace, setAttachment, toStringpublic FunctionTask(Function<R,A> runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut)
invokeAndWait().runnable - the user actionsyncObject - the synchronization object the caller shall wait until runnable execution is completed,
or null if waiting is not desired.catchExceptions - Influence an occurring exception during runnable execution.
If true, the exception is silenced and can be retrieved via TaskBase.getThrowable(),
otherwise the exception is thrown.exceptionOut - If not null, exceptions are written to this PrintStream.public static <U,V> U invoke(boolean waitUntilDone,
Function<U,V> func,
V... args)
Function.eval(Object...)public static <U,V> FunctionTask<U,V> invokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Function<U,V> func, V... args)
func on a new InterruptSource.Thread,
see InterruptSource.Thread#Thread(ThreadGroup, Runnable, String) for details.
The result can be retrieved via getResult(),
using the returned instance.
tg - the ThreadGroup for the new thread, maybe nullthreadName - the name for the new thread, maybe nullwaitUntilDone - if true, waits until func execution is completed, otherwise returns immediately.func - the Function to execute.args - the Function argumentsFunctionTaskpublic final void setArgs(A... args)
public final R getResult()
run()
and is cleared within this method.public final void run()
Calls eval(Object...).
You may set the eval(Object...) arguments via setArgs(Object...)
and retrieve the result via getResult().