com.jogamp.common.util
Class TaskBase

java.lang.Object
  extended by com.jogamp.common.util.TaskBase
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
FunctionTask, RunnableTask

public abstract class TaskBase
extends Object
implements Runnable

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


Field Summary
protected  Object attachment
           
protected  boolean catchExceptions
           
protected  boolean isFlushed
           
protected  Throwable runnableException
           
protected  Object syncObject
           
protected  long tCreated
           
protected  long tExecuted
           
protected  long tStarted
           
 
Constructor Summary
protected TaskBase(Object syncObject, boolean catchExceptions)
           
 
Method Summary
 void flush()
          Simply flush this task and notify a waiting executor.
 Object getAttachment()
          Return the attachment object if any.
 long getDurationInExec()
           
 long getDurationInQueue()
           
 long getDurationTotal()
           
 Object getSyncObject()
          Return the synchronization object if any.
 Throwable getThrowable()
           
 long getTimestampAfterExec()
           
 long getTimestampBeforeExec()
           
 long getTimestampCreate()
           
 boolean hasWaiter()
           
 boolean isExecuted()
           
 boolean isFlushed()
           
 boolean isInQueue()
           
abstract  void run()
           
 void setAttachment(Object o)
          Attach a custom object to this task.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

syncObject

protected final Object syncObject

catchExceptions

protected final boolean catchExceptions

attachment

protected Object attachment

runnableException

protected Throwable runnableException

tCreated

protected long tCreated

tStarted

protected long tStarted

tExecuted

protected volatile long tExecuted

isFlushed

protected volatile boolean isFlushed
Constructor Detail

TaskBase

protected TaskBase(Object syncObject,
                   boolean catchExceptions)
Method Detail

getSyncObject

public final Object getSyncObject()
Return the synchronization object if any.

See Also:
#RunnableTask(Runnable, Object, boolean)

setAttachment

public final void setAttachment(Object o)
Attach a custom object to this task. Useful to piggybag further information, ie tag a task final.


getAttachment

public final Object getAttachment()
Return the attachment object if any.

See Also:
setAttachment(Object)

run

public abstract void run()
Specified by:
run in interface Runnable

flush

public final void flush()
Simply flush this task and notify a waiting executor. The executor which might have been blocked until notified will be unblocked and the task removed from the queue.

See Also:
isFlushed(), isInQueue()

isInQueue

public final boolean isInQueue()
Returns:
!isExecuted() && !isFlushed()

isExecuted

public final boolean isExecuted()
Returns:
True if executed, otherwise false;

isFlushed

public final boolean isFlushed()
Returns:
True if flushed, otherwise false;

hasWaiter

public final boolean hasWaiter()
Returns:
True if invoking thread waits until done, ie a notifyObject was passed, otherwise false;

getThrowable

public final Throwable getThrowable()
Returns:
A thrown exception while execution of the user action, if any and if catched
See Also:
#RunnableTask(Runnable, Object, boolean)

getTimestampCreate

public final long getTimestampCreate()

getTimestampBeforeExec

public final long getTimestampBeforeExec()

getTimestampAfterExec

public final long getTimestampAfterExec()

getDurationInQueue

public final long getDurationInQueue()

getDurationInExec

public final long getDurationInExec()

getDurationTotal

public final long getDurationTotal()

toString

public String toString()
Overrides:
toString in class Object