Modifier and Type | Field and Description |
---|---|
protected A[] |
args |
protected R |
result |
protected Function<R,A> |
runnable |
attachment, catchExceptions, exceptionOut, 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)
Invokes
func . |
void |
run() |
void |
setArgs(A... args)
Sets the arguments for
run() . |
flush, flush, getAttachment, getDurationInExec, getDurationInQueue, getDurationTotal, getExceptionOutIntro, getSyncObject, getThrowable, getTimestampAfterExec, getTimestampBeforeExec, getTimestampCreate, hasWaiter, isExecuted, isFlushed, isInQueue, printSourceTrace, setAttachment, toString
public 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)
func
.public 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()
.