|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpivot.util.concurrent.Task<V>
public abstract class Task<V>
Abstract base class for "tasks". A task is an asynchronous operation that may optionally return a value.
Field Summary | |
---|---|
protected boolean |
abort
|
protected long |
timeout
|
Constructor Summary | |
---|---|
Task()
|
|
Task(Dispatcher dispatcher)
|
Method Summary | |
---|---|
void |
abort()
Sets the abort flag for this task to true. |
abstract V |
execute()
Synchronously executes the task. |
void |
execute(TaskListener<V> taskListener)
Asynchronously executes the task. |
Dispatcher |
getDispatcher()
Returns the dispatcher used to execute this task. |
java.lang.Exception |
getFault()
Returns the fault that occurred while executing the task. |
V |
getResult()
Returns the result of executing the task. |
long |
getTimeout()
Returns the timeout value for this task. |
boolean |
isPending()
Returns the pending state of the task. |
void |
setTimeout(long timeout)
Sets the timeout value for this task. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected volatile long timeout
protected volatile boolean abort
Constructor Detail |
---|
public Task()
public Task(Dispatcher dispatcher)
Method Detail |
---|
public abstract V execute() throws TaskExecutionException
TaskExecutionException
- If an error occurs while executing the task.public void execute(TaskListener<V> taskListener)
taskListener
- The listener to be notified when the task completes.public Dispatcher getDispatcher()
public V getResult()
isPending()
and getFault()
to distinguish
between these cases.public java.lang.Exception getFault()
isPending()
to distinguish
between these cases.public boolean isPending()
public long getTimeout()
setTimeout(long)
public void setTimeout(long timeout)
timeout
- The time by which the task must complete execution. If the timeout is
exceeded, a TimeoutException
will be thrown.public void abort()
AbortException
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |