|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.util.concurrent.JdkFutureAdapters
@Beta public final class JdkFutureAdapters
Utilities necessary for working with libraries that supply plain Future
instances. Note that, whenver possible, it is strongly preferred to
modify those libraries to return ListenableFuture
directly.
Futures.makeListenable
, which
existed in 1.0)Method Summary | ||
---|---|---|
static
|
listenInPoolThread(Future<V> future)
Assigns a thread to the given Future to provide ListenableFuture functionality. |
|
static
|
listenInPoolThread(Future<V> future,
Executor executor)
Submits a blocking task for the given Future to provide ListenableFuture functionality. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <V> ListenableFuture<V> listenInPoolThread(Future<V> future)
Future
to provide ListenableFuture
functionality.
Warning: If the input future does not already implement ListenableFuture
, the returned future will emulate ListenableFuture.addListener(java.lang.Runnable, java.util.concurrent.Executor)
by taking a thread from an internal,
unbounded pool at the first call to addListener
and holding it
until the future is done.
Prefer to create ListenableFuture
instances with SettableFuture
, MoreExecutors.listeningDecorator(
java.util.concurrent.ExecutorService)
, ListenableFutureTask
,
AbstractFuture
, and other utilities over creating plain Future
instances to be upgraded to ListenableFuture
after the
fact.
public static <V> ListenableFuture<V> listenInPoolThread(Future<V> future, Executor executor)
Future
to provide ListenableFuture
functionality.
Warning: If the input future does not already implement ListenableFuture
, the returned future will emulate ListenableFuture.addListener(java.lang.Runnable, java.util.concurrent.Executor)
by submitting a task to the given executor at
at the first call to addListener
. The task must be started by the
executor promptly, or else the returned ListenableFuture
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 with SettableFuture
, MoreExecutors.listeningDecorator(
java.util.concurrent.ExecutorService)
, ListenableFutureTask
,
AbstractFuture
, and other utilities over creating plain Future
instances to be upgraded to ListenableFuture
after the
fact.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |