T
- The result object type returned by this futurepublic class ScheduledFutureDelegate<T> extends java.lang.Object implements ListenableScheduledFuture<T>
ListenableScheduledFuture
interface. This design delegates
between a Delayed
instance and ListenableFuture
instance.Constructor and Description |
---|
ScheduledFutureDelegate(ListenableFuture<? extends T> futureImp,
java.util.concurrent.Delayed delayed)
Constructs a new
ScheduledFutureDelegate with the provided instances to call to for
each interface. |
Modifier and Type | Method and Description |
---|---|
void |
addCallback(FutureCallback<? super T> callback)
Add a
FutureCallback to be called once the future has completed. |
void |
addCallback(FutureCallback<? super T> callback,
java.util.concurrent.Executor executor)
Add a
FutureCallback to be called once the future has completed. |
void |
addListener(java.lang.Runnable listener)
Add a listener to be called once the future has completed.
|
void |
addListener(java.lang.Runnable listener,
java.util.concurrent.Executor executor)
Add a listener to be called once the future has completed.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
int |
compareTo(java.util.concurrent.Delayed o) |
T |
get() |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
long |
getDelay(java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flatMap, flatMap, map, map
public ScheduledFutureDelegate(ListenableFuture<? extends T> futureImp, java.util.concurrent.Delayed delayed)
ScheduledFutureDelegate
with the provided instances to call to for
each interface.futureImp
- implementation to call to for all Future callsdelayed
- implementation to call to for getDelay and compareTopublic long getDelay(java.util.concurrent.TimeUnit unit)
getDelay
in interface java.util.concurrent.Delayed
public int compareTo(java.util.concurrent.Delayed o)
compareTo
in interface java.lang.Comparable<java.util.concurrent.Delayed>
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
public void addListener(java.lang.Runnable listener)
ListenableFuture
The listener from this call will execute on the same thread the result was produced on, or on
the adding thread if the future is already complete. If the runnable has high complexity,
consider using ListenableFuture.addListener(Runnable, Executor)
.
addListener
in interface ListenableFuture<T>
listener
- the listener to run when the computation is completepublic void addListener(java.lang.Runnable listener, java.util.concurrent.Executor executor)
ListenableFuture
If the provided Executor
is null, the listener will execute on the thread which
computed the original future (once it is done). If the future has already completed, the
listener will execute immediately on the thread which is adding the listener.
addListener
in interface ListenableFuture<T>
listener
- the listener to run when the computation is completeexecutor
- Executor
the listener should be ran on, or null
public void addCallback(FutureCallback<? super T> callback)
ListenableFuture
FutureCallback
to be called once the future has completed. If the future has
already finished, this will be called immediately.
The callback from this call will execute on the same thread the result was produced on, or on the adding thread if the future is already complete. If the callback has high complexity, consider passing an executor in for it to be called on.
addCallback
in interface ListenableFuture<T>
callback
- to be invoked when the computation is completepublic void addCallback(FutureCallback<? super T> callback, java.util.concurrent.Executor executor)
ListenableFuture
FutureCallback
to be called once the future has completed. If the future has
already finished, this will be called immediately.
If the provided Executor
is null, the callback will execute on the thread which
computed the original future (once it is done). If the future has already completed, the
callback will execute immediately on the thread which is adding the callback.
addCallback
in interface ListenableFuture<T>
callback
- to be invoked when the computation is completeexecutor
- Executor
the callback should be ran on, or null