Package com.jogamp.common.util
Class RunnableTask
- java.lang.Object
-
- com.jogamp.common.util.TaskBase
-
- com.jogamp.common.util.RunnableTask
-
-
Field Summary
Fields Modifier and Type Field Description protected Runnable
runnable
-
Fields inherited from class com.jogamp.common.util.TaskBase
attachment, catchExceptions, exceptionOut, execThread, isExecuted, isFlushed, runnableException, sourceStack, syncObject, tCreated, tExecuted, tStarted
-
-
Constructor Summary
Constructors Constructor Description RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut)
Create a RunnableTask object w/ synchronization, ie.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Runnable
getRunnable()
Return the user actionstatic RunnableTask
invokeOnCurrentThread(Runnable runnable)
Invokesrunnable
on the currentThread
.static RunnableTask
invokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Runnable runnable)
Invokesrunnable
on a newInterruptSource.Thread
, seeThread(ThreadGroup, Runnable, String)
for details.void
run()
-
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 Detail
-
runnable
protected final Runnable runnable
-
-
Constructor Detail
-
RunnableTask
public RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut)
Create a RunnableTask object w/ synchronization, ie. suitable forinvokeAndWait()
, i.e.invoke(true, runnable)
.- Parameters:
runnable
- The user actionsyncObject
- The synchronization object if caller wait untilrunnable
execution is completed, ornull
if waiting is not desired.catchExceptions
- Influence an occurring exception duringrunnable
execution. 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 Detail
-
invokeOnCurrentThread
public static RunnableTask invokeOnCurrentThread(Runnable runnable)
Invokesrunnable
on the currentThread
.- Parameters:
runnable
- theRunnable
to execute on the current thread. The runnable must exit, i.e. not loop forever.- Returns:
- the newly created and invoked
RunnableTask
- Since:
- 2.4.0
-
invokeOnNewThread
public static RunnableTask invokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Runnable runnable)
Invokesrunnable
on a newInterruptSource.Thread
, seeThread(ThreadGroup, Runnable, String)
for details.- Parameters:
tg
- theThreadGroup
for the new thread, maybenull
threadName
- the name for the new thread, maybenull
waitUntilDone
- iftrue
, waits untilrunnable
execution is completed, otherwise returns immediately.runnable
- theRunnable
to execute on the new thread. IfwaitUntilDone
istrue
, the runnable must exit, i.e. not loop forever.- Returns:
- the newly created and invoked
RunnableTask
- Since:
- 2.3.2
-
getRunnable
public final Runnable getRunnable()
Return the user action
-
-