T
- The result object type returned by this future@Deprecated public class ScheduledFutureDelegate<T> extends java.lang.Object implements ListenableScheduledFuture<T>
ListenableScheduledFuture
interface. This design delegates
between a Delayed
instance and ListenableFuture
instance.ListenableFuture.ListenerOptimizationStrategy
Constructor and Description |
---|
ScheduledFutureDelegate(ListenableFuture<? extends T> futureImp,
java.util.concurrent.Delayed delayed)
Deprecated.
Constructs a new
ScheduledFutureDelegate with the provided instances to call to for
each interface. |
Modifier and Type | Method and Description |
---|---|
ListenableFuture<T> |
callback(FutureCallback<? super T> callback,
java.util.concurrent.Executor executor,
ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
Deprecated.
Add a
FutureCallback to be called once the future has completed. |
boolean |
cancel(boolean mayInterruptIfRunning)
Deprecated.
|
int |
compareTo(java.util.concurrent.Delayed o)
Deprecated.
|
ListenableFuture<T> |
failureCallback(java.util.function.Consumer<java.lang.Throwable> callback,
java.util.concurrent.Executor executor,
ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
Deprecated.
Add a
Consumer to be called once the future has completed. |
T |
get()
Deprecated.
|
T |
get(long timeout,
java.util.concurrent.TimeUnit unit)
Deprecated.
|
long |
getDelay(java.util.concurrent.TimeUnit unit)
Deprecated.
|
java.lang.StackTraceElement[] |
getRunningStackTrace()
Deprecated.
A best effort to return the stack trace for for the executing thread of either this future,
or a future which this depends on through the use of
ListenableFuture.map(Function) or similar
functions. |
boolean |
isCancelled()
Deprecated.
|
boolean |
isDone()
Deprecated.
|
ListenableFuture<T> |
listener(java.lang.Runnable listener,
java.util.concurrent.Executor executor,
ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
Deprecated.
Add a listener to be called once the future has completed.
|
ListenableFuture<T> |
resultCallback(java.util.function.Consumer<? super T> callback,
java.util.concurrent.Executor executor,
ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
Deprecated.
Add a
Consumer to be called once the future has completed. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addCallback, addCallback, addCallback, addListener, addListener, addListener, callback, callback, failureCallback, failureCallback, flatMap, flatMap, flatMap, flatMap, flatMapFailure, flatMapFailure, flatMapFailure, listener, listener, map, map, map, mapFailure, mapFailure, mapFailure, resultCallback, resultCallback, throwMap, throwMap, throwMap
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 ListenableFuture<T> listener(java.lang.Runnable listener, java.util.concurrent.Executor executor, ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
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.
Caution should be used when choosing to optimize the listener execution. If the listener is
complex, or wanting to be run concurrent, this optimization could prevent that. In addition
it will prevent other listeners from potentially being invoked until it completes. However
if the listener is small / fast, this can provide significant performance gains. It should
also be known that not all ListenableFuture
implementations may be able to do such an
optimization. Please see ListenableFuture.ListenerOptimizationStrategy
javadocs for more specific
details of what optimizations are available.
listener
in interface ListenableFuture<T>
listener
- the listener to run when the computation is completeexecutor
- Executor
the listener should be ran on, or null
optimizeExecution
- true
to avoid listener queuing for execution if already on the desired poolthis
instance to add more listeners or other functional operationspublic ListenableFuture<T> callback(FutureCallback<? super T> callback, java.util.concurrent.Executor executor, ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
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.
Caution should be used when choosing to optimize the listener execution. If the listener is
complex, or wanting to be run concurrent, this optimization could prevent that. In addition
it will prevent other listeners from potentially being invoked until it completes. However
if the listener is small / fast, this can provide significant performance gains. It should
also be known that not all ListenableFuture
implementations may be able to do such an
optimization. Please see ListenableFuture.ListenerOptimizationStrategy
javadocs for more specific
details of what optimizations are available.
If you only care about the success result case please see
ListenableFuture.resultCallback(Consumer, Executor, ListenerOptimizationStrategy)
or conversely if you
only want to be invoked for failure cases please see
ListenableFuture.failureCallback(Consumer, Executor, ListenerOptimizationStrategy)
.
callback
in interface ListenableFuture<T>
callback
- to be invoked when the computation is completeexecutor
- Executor
the callback should be ran on, or null
optimizeExecution
- true
to avoid listener queuing for execution if already on the desired poolthis
instance to add more callbacks or other functional operationspublic ListenableFuture<T> resultCallback(java.util.function.Consumer<? super T> callback, java.util.concurrent.Executor executor, ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
ListenableFuture
Consumer
to be called once the future has completed. If the future has
already finished, this will be called immediately. Assuming the future has completed without
error, the result will be provided to the Consumer
, otherwise it will go un-invoked.
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.
Caution should be used when choosing to optimize the listener execution. If the listener is
complex, or wanting to be run concurrent, this optimization could prevent that. In addition
it will prevent other listeners from potentially being invoked until it completes. However
if the listener is small / fast, this can provide significant performance gains. It should
also be known that not all ListenableFuture
implementations may be able to do such an
optimization. Please see ListenableFuture.ListenerOptimizationStrategy
javadocs for more specific
details of what optimizations are available.
resultCallback
in interface ListenableFuture<T>
callback
- to be invoked when the computation is completeexecutor
- Executor
the callback should be ran on, or null
optimizeExecution
- true
to avoid listener queuing for execution if already on the desired poolthis
instance to add more callbacks or other functional operationspublic ListenableFuture<T> failureCallback(java.util.function.Consumer<java.lang.Throwable> callback, java.util.concurrent.Executor executor, ListenableFuture.ListenerOptimizationStrategy optimizeExecution)
ListenableFuture
Consumer
to be called once the future has completed. If the future has
already finished, this will be called immediately. Assuming the future has completed with an
error, the Throwable
will be provided to the Consumer
, otherwise if no error
occurred, the callback will go un-invoked.
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.
Caution should be used when choosing to optimize the listener execution. If the listener is
complex, or wanting to be run concurrent, this optimization could prevent that. In addition
it will prevent other listeners from potentially being invoked until it completes. However
if the listener is small / fast, this can provide significant performance gains. It should
also be known that not all ListenableFuture
implementations may be able to do such an
optimization. Please see ListenableFuture.ListenerOptimizationStrategy
javadocs for more specific
details of what optimizations are available.
failureCallback
in interface ListenableFuture<T>
callback
- to be invoked when the computation is completeexecutor
- Executor
the callback should be ran on, or null
optimizeExecution
- true
to avoid listener queuing for execution if already on the desired poolthis
instance to add more callbacks or other functional operationspublic java.lang.StackTraceElement[] getRunningStackTrace()
ListenableFuture
ListenableFuture.map(Function)
or similar
functions. If there is no thread executing the future yet, or the future has already
completed, then this will return null
.
This is done without locking (though generating a stack trace still requires a JVM safe point), so the resulting stack trace is NOT guaranteed to be accurate. In most cases (particularly when blocking) this should be accurate though.
getRunningStackTrace
in interface ListenableFuture<T>
null
if unavailable