GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
com.jogamp.common.util.FunctionTask< R, A > Class Template Reference

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

Inheritance diagram for com.jogamp.common.util.FunctionTask< R, A >:
Collaboration diagram for com.jogamp.common.util.FunctionTask< R, A >:

Public Member Functions

 FunctionTask (final Function< R, A > runnable, final Object syncObject, final boolean catchExceptions, final PrintStream exceptionOut)
 Create a RunnableTask object w/ synchronization, ie. More...
 
final Function< R, A > getRunnable ()
 Return the user action. More...
 
final void setArgs (final A... args)
 Sets the arguments for run(). More...
 
final R getResult ()
 Retrieves the cached result of run() and is cleared within this method. More...
 
final void run ()
 
final R eval (final A... args)
 Implementation may compute variable args list and returns a result. More...
 
- Public Member Functions inherited from com.jogamp.common.util.TaskBase
final Thread getExecutionThread ()
 Returns the execution thread or null if not yet run(). More...
 
final Object getSyncObject ()
 Return the synchronization object if any. More...
 
final void setAttachment (final Object o)
 Attach a custom object to this task. More...
 
final Object getAttachment ()
 Return the attachment object if any. More...
 
abstract void run ()
 
final void flush (final Throwable t)
 Simply flush this task and notify a waiting executor. More...
 
final boolean isInQueue ()
 
final boolean isExecuted ()
 
final boolean isFlushed ()
 
final boolean hasWaiter ()
 
final Throwable getThrowable ()
 
final long getTimestampCreate ()
 
final long getTimestampBeforeExec ()
 
final long getTimestampAfterExec ()
 
final long getDurationInQueue ()
 
final long getDurationInExec ()
 
final long getDurationTotal ()
 
String toString ()
 
eval (A... args)
 Implementation may compute variable args list and returns a result. More...
 

Static Public Member Functions

static< U, V > FunctionTask< U, V > invokeOnCurrentThread (final Function< U, V > func, final V... args)
 Invokes func on the current Thread. More...
 
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. More...
 

Protected Attributes

Function< R, A > runnable
 
result
 
A[] args
 
- Protected Attributes inherited from com.jogamp.common.util.TaskBase
final Object syncObject
 
final boolean catchExceptions
 
final PrintStream exceptionOut
 
final Throwable sourceStack
 
Object attachment
 
Throwable runnableException
 
long tCreated
 
long tStarted
 
volatile long tExecuted
 
volatile boolean isExecuted
 
volatile boolean isFlushed
 
volatile Thread execThread
 

Additional Inherited Members

- Protected Member Functions inherited from com.jogamp.common.util.TaskBase
 TaskBase (final Object syncObject, final boolean catchExceptions, final PrintStream exceptionOut)
 
final String getExceptionOutIntro ()
 
final void printSourceTrace ()
 

Detailed Description

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

Definition at line 39 of file FunctionTask.java.

Constructor & Destructor Documentation

◆ FunctionTask()

com.jogamp.common.util.FunctionTask< R, A >.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
runnablethe user action
syncObjectthe synchronization object the caller shall wait until runnable execution is completed, or null if waiting is not desired.
catchExceptionsInfluence an occurring exception during runnable execution. If true, the exception is silenced and can be retrieved via getThrowable(), otherwise the exception is thrown.
exceptionOutIf not null, exceptions are written to this PrintStream.

Definition at line 120 of file FunctionTask.java.

Member Function Documentation

◆ eval()

final R com.jogamp.common.util.FunctionTask< R, A >.eval ( final A...  args)

Implementation may compute variable args list and returns a result.

Parameters
argsvariable argument list, A[], maybe null
Returns
the result.

Implements com.jogamp.common.util.Function< R, A >.

Definition at line 210 of file FunctionTask.java.

Here is the call graph for this function:

◆ getResult()

final R com.jogamp.common.util.FunctionTask< R, A >.getResult ( )

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

Definition at line 144 of file FunctionTask.java.

◆ getRunnable()

final Function< R, A > com.jogamp.common.util.FunctionTask< R, A >.getRunnable ( )

Return the user action.

Definition at line 128 of file FunctionTask.java.

◆ invokeOnCurrentThread()

static< U, V > FunctionTask< U, V > com.jogamp.common.util.FunctionTask< R, A >.invokeOnCurrentThread ( final Function< U, V >  func,
final V...  args 
)
static

Invokes func on the current Thread.

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

Parameters
functhe Function to execute.
argsthe Function arguments
Returns
the newly created and invoked FunctionTask
Since
2.4.0

Definition at line 55 of file FunctionTask.java.

Here is the call graph for this function:

◆ invokeOnNewThread()

static< U, V > FunctionTask< U, V > com.jogamp.common.util.FunctionTask< R, A >.invokeOnNewThread ( final ThreadGroup  tg,
final String  threadName,
final boolean  waitUntilDone,
final Function< U, V >  func,
final V...  args 
)
static

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
tgthe ThreadGroup for the new thread, maybe null
threadNamethe name for the new thread, maybe null
waitUntilDoneif true, waits until func execution is completed, otherwise returns immediately.
functhe Function to execute.
argsthe Function arguments
Returns
the newly created and invoked FunctionTask
Since
2.3.2

Definition at line 77 of file FunctionTask.java.

Here is the call graph for this function:

◆ run()

final void com.jogamp.common.util.FunctionTask< R, A >.run ( )

Calls eval(Object...).

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

Reimplemented from com.jogamp.common.util.TaskBase.

Definition at line 161 of file FunctionTask.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setArgs()

final void com.jogamp.common.util.FunctionTask< R, A >.setArgs ( final A...  args)

Sets the arguments for run().

They will be cleared after calling run() or eval(Object...).

Definition at line 136 of file FunctionTask.java.

Member Data Documentation

◆ args

A [] com.jogamp.common.util.FunctionTask< R, A >.args
protected

Definition at line 42 of file FunctionTask.java.

◆ result

R com.jogamp.common.util.FunctionTask< R, A >.result
protected

Definition at line 41 of file FunctionTask.java.

◆ runnable

Function<R,A> com.jogamp.common.util.FunctionTask< R, A >.runnable
protected

Definition at line 40 of file FunctionTask.java.


The documentation for this class was generated from the following file: