com.google.common.util.concurrent
Class JdkFutureAdapters

java.lang.Object
  extended by com.google.common.util.concurrent.JdkFutureAdapters

@Beta
public final class JdkFutureAdapters
extends Object

Utilities necessary for working with libraries that supply plain Future instances.

Since:
10.0 (replacing Futures.makeListenable, which existed in 1.0)
Author:
Sven Mawson

Method Summary
static
<V> ListenableFuture<V>
listenInPoolThread(Future<V> future)
          Assigns a thread to 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

listenInPoolThread

public static <V> ListenableFuture<V> listenInPoolThread(Future<V> future)
Assigns a thread to the given 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.



Copyright © 2010-2011. All Rights Reserved.