T
- Type of result returned from the futurepublic class ListenableFutureAdapterTask<T> extends ListenableFutureTask<T>
Future
to threadly's ListenableFuture
. This transfers the
state (ie result, failure, or canceled) from the source future. In order for this translation
to occur a thread is needed to notify potential listeners when the future completes. When
ListenableFutureTask.run()
is invoked we will block (if delegate future is not complete)
waiting for the result from the provided future. Completing with the same state once the
provided future completes.
The most common way to use this class is to construct it with the future to adapt from, then provide this future to an executor to block waiting for the provided future to complete. If this is used for high quantities keep in mind a lot of the threads will idly be waiting for results, typically a native threadly pool may be a better option.
ListenableFuture.ListenerOptimizationStrategy
Constructor and Description |
---|
ListenableFutureAdapterTask(java.util.concurrent.Future<? extends T> f)
Constructs a new
ListenableFutureAdapterTask . |
Modifier and Type | Method and Description |
---|---|
void |
run() |
addListener, getContainedCallable
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addCallback, addCallback, addCallback, addListener, addListener, flatMap, flatMap, flatMap, map, map, map
public ListenableFutureAdapterTask(java.util.concurrent.Future<? extends T> f)
ListenableFutureAdapterTask
.f
- Future to get result and source final state frompublic void run()
run
in interface java.lang.Runnable
run
in interface java.util.concurrent.RunnableFuture<T>
run
in class ListenableFutureTask<T>