Package com.jogamp.common.util
Class FunctionTask<R,A>
java.lang.Object
com.jogamp.common.util.TaskBase
com.jogamp.common.util.FunctionTask<R,A>
Helper class to provide a Runnable queue implementation with a Runnable wrapper
which notifies after execution for the
invokeAndWait() semantics.-
Field Summary
FieldsFields inherited from class com.jogamp.common.util.TaskBase
attachment, catchExceptions, exceptionOut, execThread, isExecuted, isFlushed, runnableException, sourceStack, syncObject, tCreated, tExecuted, tStarted -
Constructor Summary
ConstructorsConstructorDescriptionFunctionTask(Function<R, A> runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut) Create a RunnableTask object w/ synchronization, ie. -
Method Summary
Modifier and TypeMethodDescriptionfinal RImplementation may compute variableargslist and returns a result.final RRetrieves the cached result ofrun()and is cleared within this method.Return the user actionstatic <U,V> U Deprecated.static <U,V> FunctionTask<U, V> invokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Function<U, V> func, V... args) Invokesfuncon a newInterruptSource.Thread, seeThread(ThreadGroup, Runnable, String)for details.final voidrun()final voidSets the arguments forrun().Methods inherited from class com.jogamp.common.util.TaskBase
flush, getAttachment, getDurationInExec, getDurationInQueue, getDurationTotal, getExceptionOutIntro, getExecutionThread, getSyncObject, getThrowable, getTimestampAfterExec, getTimestampBeforeExec, getTimestampCreate, hasWaiter, isExecuted, isFlushed, isInQueue, printSourceTrace, setAttachment, toString
-
Field Details
-
runnable
-
result
-
args
-
-
Constructor Details
-
FunctionTask
public FunctionTask(Function<R, A> runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut) Create a RunnableTask object w/ synchronization, ie. suitable forinvokeAndWait().- Parameters:
runnable- the user actionsyncObject- the synchronization object the caller shall wait untilrunnableexecution is completed, ornullif waiting is not desired.catchExceptions- Influence an occurring exception duringrunnableexecution. Iftrue, the exception is silenced and can be retrieved viaTaskBase.getThrowable(), otherwise the exception is thrown.exceptionOut- If notnull, exceptions are written to thisPrintStream.
-
-
Method Details
-
invoke
Deprecated.Simply invokeFunction.eval(Object...) -
invokeOnNewThread
public static <U,V> FunctionTask<U,V> invokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Function<U, V> func, V... args) Invokesfuncon a newInterruptSource.Thread, seeThread(ThreadGroup, Runnable, String)for details.The result can be retrieved via
getResult(), using the returned instance.- Parameters:
tg- theThreadGroupfor the new thread, maybenullthreadName- the name for the new thread, maybenullwaitUntilDone- iftrue, waits untilfuncexecution is completed, otherwise returns immediately.func- theFunctionto execute.args- theFunctionarguments- Returns:
- the newly created and invoked
FunctionTask - Since:
- 2.3.2
-
getRunnable
Return the user action -
setArgs
-
getResult
Retrieves the cached result ofrun()and is cleared within this method. -
run
public final void run()Calls
eval(Object...).You may set the
eval(Object...)arguments viasetArgs(Object...)and retrieve the result viagetResult(). -
eval
Description copied from interface:FunctionImplementation may compute variableargslist and returns a result.
-
Function.eval(Object...)