com.jogamp.common.util
Class RunnableTask

java.lang.Object
  extended by com.jogamp.common.util.RunnableTask
All Implemented Interfaces:
Runnable

public class RunnableTask
extends Object
implements Runnable

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


Constructor Summary
RunnableTask(Runnable runnable)
          Create a RunnableTask object w/o synchronization, ie.
RunnableTask(Runnable runnable, Object syncObject)
          Create a RunnableTask object w/ synchronization, ie.
RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions)
          Create a RunnableTask object w/ synchronization, ie.
 
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()
           
 Runnable getRunnable()
          Return the user action
 Object getSyncObject()
          Return the synchronization object if any.
 Throwable getThrowable()
           
 long getTimestampAfterExec()
           
 long getTimestampBeforeExec()
           
 long getTimestampCreate()
           
 boolean hasWaiter()
           
 boolean isExecuted()
           
 boolean isFlushed()
           
 boolean isInQueue()
           
 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
 

Constructor Detail

RunnableTask

public RunnableTask(Runnable runnable)
Create a RunnableTask object w/o synchronization, ie. not suitable for invokeAndWait().

Parameters:
runnable - the user action

RunnableTask

public RunnableTask(Runnable runnable,
                    Object syncObject)
Create a RunnableTask object w/ synchronization, ie. suitable for invokeAndWait().

Parameters:
runnable - the user action
syncObject - the synchronization object the caller shall wait for in case of invokeAndWait()

RunnableTask

public RunnableTask(Runnable runnable,
                    Object syncObject,
                    boolean catchExceptions)
Create a RunnableTask object w/ synchronization, ie. suitable for invokeAndWait().

Parameters:
runnable - the user action
syncObject - the synchronization object the caller shall wait for in case of invokeAndWai()t
catchExceptions - if true, exception during runnable execution are catched, otherwise not. Use getThrowable() to determine whether an exception has been catched.
Method Detail

getRunnable

public Runnable getRunnable()
Return the user action


getSyncObject

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

See Also:
RunnableTask(Runnable, Object, boolean)

setAttachment

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


getAttachment

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

See Also:
setAttachment(Object)

run

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

flush

public 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 boolean isInQueue()
Returns:
!isExecuted() && !isFlushed()

isExecuted

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

isFlushed

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

hasWaiter

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

getThrowable

public 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 long getTimestampCreate()

getTimestampBeforeExec

public long getTimestampBeforeExec()

getTimestampAfterExec

public long getTimestampAfterExec()

getDurationInQueue

public long getDurationInQueue()

getDurationInExec

public long getDurationInExec()

getDurationTotal

public long getDurationTotal()

toString

public String toString()
Overrides:
toString in class Object