public class JDKFuture<V> extends AbstractListenableFuture<V>
ListenableFuture.CompletedFailure<T>
Modifier and Type | Field and Description |
---|---|
protected AsyncHandler<V> |
asyncHandler |
protected AtomicBoolean |
cancelled |
protected AtomicBoolean |
contentProcessed |
protected AtomicReference<Throwable> |
exception |
protected Future<V> |
innerFuture |
protected AtomicBoolean |
isDone |
protected int |
responseTimeoutInMs |
protected AtomicBoolean |
timedOut |
protected AtomicLong |
touch |
protected HttpURLConnection |
urlConnection |
Constructor and Description |
---|
JDKFuture(AsyncHandler<V> asyncHandler,
int responseTimeoutInMs,
HttpURLConnection urlConnection) |
Modifier and Type | Method and Description |
---|---|
void |
abort(Throwable t)
|
boolean |
cancel(boolean mayInterruptIfRunning) |
void |
content(V v) |
void |
done()
Terminate and if there is no exception, mark this Future as done and release the internal lock.
|
V |
get() |
V |
get(long timeout,
TimeUnit unit) |
boolean |
hasExpired()
Is the Future still valid
|
boolean |
isCancelled() |
boolean |
isDone() |
protected void |
setInnerFuture(Future<V> innerFuture) |
void |
touch()
Touch the current instance to prevent external service to times out.
|
addListener, runListeners
protected final AsyncHandler<V> asyncHandler
protected final int responseTimeoutInMs
protected final AtomicBoolean cancelled
protected final AtomicBoolean timedOut
protected final AtomicBoolean isDone
protected final AtomicReference<Throwable> exception
protected final AtomicLong touch
protected final AtomicBoolean contentProcessed
protected final HttpURLConnection urlConnection
public JDKFuture(AsyncHandler<V> asyncHandler, int responseTimeoutInMs, HttpURLConnection urlConnection)
public void done()
ListenableFuture
public void abort(Throwable t)
ListenableFuture
public void content(V v)
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
public boolean isDone()
public V get() throws InterruptedException, ExecutionException
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
public boolean hasExpired()
true
if response has expired and should be terminated.public void touch()
ListenableFuture
Copyright © 2014. All Rights Reserved.