Class JdkFutureAdapters
Future
instances. Note that, whenver possible, it is strongly preferred to
modify those libraries to return ListenableFuture
directly.- Since:
- 10.0 (replacing
Futures.makeListenable
, which existed in 1.0)
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> ListenableFuture
<V> listenInPoolThread
(Future<V> future) Deprecated.Assigns a thread to the givenFuture
to provideListenableFuture
functionality.static <V> ListenableFuture
<V> listenInPoolThread
(Future<V> future, Executor executor) Deprecated.Submits a blocking task for the givenFuture
to provideListenableFuture
functionality.
-
Method Details
-
listenInPoolThread
Deprecated.Assigns a thread to the givenFuture
to provideListenableFuture
functionality.Warning: If the input future does not already implement
ListenableFuture
, the returned future will emulateListenableFuture.addListener(java.lang.Runnable, java.util.concurrent.Executor)
by taking a thread from an internal, unbounded pool at the first call toaddListener
and holding it until the future is done.Prefer to create
ListenableFuture
instances withSettableFuture
,MoreExecutors.listeningDecorator(java.util.concurrent.ExecutorService)
,ListenableFutureTask
,AbstractFuture
, and other utilities over creating plainFuture
instances to be upgraded toListenableFuture
after the fact. -
listenInPoolThread
Deprecated.Submits a blocking task for the givenFuture
to provideListenableFuture
functionality.Warning: If the input future does not already implement
ListenableFuture
, the returned future will emulateListenableFuture.addListener(java.lang.Runnable, java.util.concurrent.Executor)
by submitting a task to the given executor at the first call toaddListener
. The task must be started by the executor promptly, or else the returnedListenableFuture
may fail to work. The task's execution consists of blocking until the input future is done, so each call to this method may claim and hold a thread for an arbitrary length of time. Use of bounded executors or other executors that may fail to execute a task promptly may result in deadlocks.Prefer to create
ListenableFuture
instances withSettableFuture
,MoreExecutors.listeningDecorator(java.util.concurrent.ExecutorService)
,ListenableFutureTask
,AbstractFuture
, and other utilities over creating plainFuture
instances to be upgraded toListenableFuture
after the fact.- Since:
- 12.0
-