Package de.intarsys.tools.concurrent
Class AbstractFutureTask<R>
- java.lang.Object
-
- de.intarsys.tools.concurrent.AbstractFutureTask<R>
-
- Type Parameters:
R
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.concurrent.Future
- Direct Known Subclasses:
CallbackFutureTask
,TaskSequence
,TaskStep
public abstract class AbstractFutureTask<R> extends java.lang.Object implements java.lang.Runnable, java.util.concurrent.Future
This is an alternate implementation forFutureTask
, which is in some cases not flexible enough.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.logging.Logger
Log
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFutureTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.Throwable
basicGetException()
protected R
basicGetResult()
boolean
cancel(boolean interrupt)
protected abstract R
compute()
protected void
computeAsync()
R
get()
R
get(long pMillisecTimeout, java.util.concurrent.TimeUnit unit)
java.lang.Throwable
getException()
protected void
handleException()
protected void
handleFinally()
protected void
handleResult()
boolean
isActive()
boolean
isCancelled()
boolean
isDone()
boolean
isFailed()
void
reset()
void
run()
void
runAsync()
protected void
setException(java.lang.Throwable e)
protected void
setResult(R object)
protected void
taskCancelled()
protected void
taskFailed()
protected void
taskFinally()
protected void
taskFinished()
protected void
taskStarted()
java.lang.String
toString()
protected void
undo()
-
-
-
Method Detail
-
basicGetException
protected java.lang.Throwable basicGetException()
-
basicGetResult
protected R basicGetResult()
-
cancel
public boolean cancel(boolean interrupt)
- Specified by:
cancel
in interfacejava.util.concurrent.Future<R>
-
compute
protected abstract R compute() throws java.lang.Exception
- Throws:
java.lang.Exception
-
computeAsync
protected void computeAsync()
-
get
public R get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
get
in interfacejava.util.concurrent.Future<R>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
get
public R get(long pMillisecTimeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
get
in interfacejava.util.concurrent.Future<R>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
getException
public java.lang.Throwable getException()
-
handleException
protected final void handleException()
-
handleFinally
protected final void handleFinally()
-
handleResult
protected final void handleResult()
-
isActive
public boolean isActive()
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<R>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<R>
-
isFailed
public boolean isFailed()
-
reset
public void reset()
-
run
public final void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
runAsync
public void runAsync()
-
setException
protected void setException(java.lang.Throwable e)
-
setResult
protected void setResult(R object)
-
taskCancelled
protected void taskCancelled()
-
taskFailed
protected void taskFailed()
-
taskFinally
protected void taskFinally()
-
taskFinished
protected void taskFinished()
-
taskStarted
protected void taskStarted()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
undo
protected void undo()
-
-