Top Description Fields Constructors Methods
com.jogamp.common.util

public Class FunctionTask<R, A>

extends TaskBase
implements Function<R, A>
Class Inheritance
All Implemented Interfaces
com.jogamp.common.util.Function
Imports
java.io.PrintStream, com.jogamp.common.JogampRuntimeException

Helper class to provide a Runnable queue implementation with a Runnable wrapper which notifies after execution for the invokeAndWait() semantics.

Field Summary

Modifier and TypeField and Description
protected A[]
protected R
protected Function<R, A>
Inherited from com.jogamp.common.util.TaskBase:
attachmentcatchExceptionsexceptionOutexecThreadisExecutedisFlushedrunnableExceptionsourceStacksyncObjecttCreatedtExecutedtStarted

Constructor Summary

AccessConstructor and Description
public
FunctionTask(final Function<R, A>
the user action
runnable
,
final Object
the synchronization object the caller shall wait until runnable execution is completed, or null if waiting is not desired.
syncObject
,
final boolean
Influence an occurring exception during runnable execution. If true, the exception is silenced and can be retrieved via getThrowable(), otherwise the exception is thrown.
catchExceptions
,
final PrintStream
If not null, exceptions are written to this PrintStream.
exceptionOut
)

Create a RunnableTask object w/ synchronization, ie.

Method Summary

Modifier and TypeMethod and Description
public final R
eval(final A...
variable argument list, A[], maybe null
args
)

Implements com.jogamp.common.util.Function.eval.

Implementation may compute variable args list and returns a result.
public final R
getResult()

Retrieves the cached result of run() and is cleared within this method.

public final Function<R, A>
getRunnable()

Return the user action

public static <U, V> U
invoke(final boolean waitUntilDone, final Function<U, V> func, final V... args)

Deprecated Simply invoke Function#eval(Object...)
public static <U, V> FunctionTask<U, V>

Returns:

the newly created and invoked FunctionTask
invokeOnNewThread
(final ThreadGroup
the ThreadGroup for the new thread, maybe null
tg
,
final String
the name for the new thread, maybe null
threadName
,
final boolean
if true, waits until func execution is completed, otherwise returns immediately.
waitUntilDone
,
final Function<U, V>
the Function to execute.
func
,
final V...
the Function arguments
args
)

Invokes func on a new InterruptSource.Thread, see InterruptSource.Thread#Thread(ThreadGroup, Runnable, String) for details.

public final void
run()

Implements abstract com.jogamp.common.util.TaskBase.run.

Implements java.lang.Runnable.run.

Runs this operation.
public final void
setArgs(final A... args)

Sets the arguments for run().

Inherited from com.jogamp.common.util.TaskBase:
flushgetAttachmentgetDurationInExecgetDurationInQueuegetDurationTotalgetExceptionOutIntrogetExecutionThreadgetSyncObjectgetThrowablegetTimestampAfterExecgetTimestampBeforeExecgetTimestampCreatehasWaiterisExecutedisFlushedisInQueueprintSourceTracesetAttachmenttoString

Field Detail

argsback to summary
protected A[] args
resultback to summary
protected R result
runnableback to summary
protected Function<R, A> runnable

Constructor Detail

FunctionTaskback to summary
public FunctionTask(final Function<R, A> runnable, final Object syncObject, final boolean catchExceptions, final PrintStream exceptionOut)

Create a RunnableTask object w/ synchronization, ie. suitable for invokeAndWait().

Parameters
runnable:Function<R, A>

the user action

syncObject:Object

the synchronization object the caller shall wait until runnable execution is completed, or null if waiting is not desired.

catchExceptions:boolean

Influence an occurring exception during runnable execution. If true, the exception is silenced and can be retrieved via getThrowable(), otherwise the exception is thrown.

exceptionOut:PrintStream

If not null, exceptions are written to this PrintStream.

Method Detail

evalback to summary
public final R eval(final A... args)

Implements com.jogamp.common.util.Function.eval.

Doc from com.jogamp.common.util.Function.eval.

Implementation may compute variable args list and returns a result.

Parameters
args:A[]

variable argument list, A[], maybe null

Returns:R

the result.

Annotations
@Override
getResultback to summary
public final R getResult()

Retrieves the cached result of run() and is cleared within this method.

getRunnableback to summary
public final Function<R, A> getRunnable()

Return the user action

invokeback to summary
public static <U, V> U invoke(final boolean waitUntilDone, final Function<U, V> func, final V... args)

Deprecated

Simply invoke Function#eval(Object...)

invokeOnNewThreadback to summary
public static <U, V> FunctionTask<U, V> invokeOnNewThread(final ThreadGroup tg, final String threadName, final boolean waitUntilDone, final Function<U, V> func, final V... args)

Invokes func on a new InterruptSource.Thread, see InterruptSource.Thread#Thread(ThreadGroup, Runnable, String) for details.

The result can be retrieved via FunctionTask#getResult(), using the returned instance.

Parameters
tg:ThreadGroup

the ThreadGroup for the new thread, maybe null

threadName:String

the name for the new thread, maybe null

waitUntilDone:boolean

if true, waits until func execution is completed, otherwise returns immediately.

func:Function<U, V>

the Function to execute.

args:V[]

the Function arguments

Returns:FunctionTask<U, V>

the newly created and invoked FunctionTask

Since
2.3.2
runback to summary
public final void run()

Implements abstract com.jogamp.common.util.TaskBase.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Calls eval(Object...).

You may set the eval(Object...) arguments via setArgs(Object...) and retrieve the result via getResult().

Annotations
@Override
setArgsback to summary
public final void setArgs(final A... args)

Sets the arguments for run(). They will be cleared after calling run() or eval(Object...).