T
- the result type returned by this Future's get methodpublic class FutureWithStatisticsImpl<T> extends java.lang.Object implements FutureWithStatistics<T>
FutureWithStatistics
.
The instance is created and then the executed future is setConstructor and Description |
---|
FutureWithStatisticsImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addStats(java.lang.Iterable<Statistics<?>> stats)
Collect the gathered statistics.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
java.util.Iterator<Statistics<?>> |
iterator() |
protected void |
setCallable(java.util.concurrent.Callable<T> callable)
Sets the callable for immediate execution.
|
protected void |
setFuture(java.util.concurrent.Future<T> future)
Sets the encapsulated future object.
|
static <T extends AbstractOperation> |
submit(java.util.concurrent.ExecutorService executorService,
java.util.concurrent.Callable<T> callable)
Executes the given callable and collects the
OperationStatistics . |
protected final void setFuture(java.util.concurrent.Future<T> future)
future
- the encapsulated future objectprotected final void setCallable(java.util.concurrent.Callable<T> callable)
callable
- the callable for immediate executionprotected final void addStats(java.lang.Iterable<Statistics<?>> stats)
stats
- the gathered statisticspublic static <T extends AbstractOperation> FutureWithStatistics<T> submit(java.util.concurrent.ExecutorService executorService, java.util.concurrent.Callable<T> callable) throws java.util.concurrent.RejectedExecutionException, java.lang.NullPointerException
OperationStatistics
.T
- the type of value returned by the given callableexecutorService
- the executor used to run the callablecallable
- the callable to runjava.util.concurrent.RejectedExecutionException
- if the callable was no accepted by the executor servicejava.lang.NullPointerException
- if the callable was nullpublic java.util.Iterator<Statistics<?>> iterator()
iterator
in interface java.lang.Iterable<Statistics<?>>
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<T>
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<T>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<T>
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException