com.google.common.util.concurrent
Class SettableFuture<V>

java.lang.Object
  extended by com.google.common.util.concurrent.AbstractFuture<V>
      extended by com.google.common.util.concurrent.SettableFuture<V>
All Implemented Interfaces:
ListenableFuture<V>, Future<V>

public final class SettableFuture<V>
extends AbstractFuture<V>

A ListenableFuture whose result may be set by a set(Object) or setException(Throwable) call. It may also be cancelled.

Since:
9.0 (in 1.0 as ValueFuture)
Author:
Sven Mawson

Method Summary
static
<V> SettableFuture<V>
create()
          Creates a new SettableFuture in the default state.
 boolean set(V value)
          Sets the value of this future.
 boolean setException(Throwable throwable)
          Sets the future to having failed with the given exception.
 
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
addListener, cancel, get, get, interruptTask, isCancelled, isDone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static <V> SettableFuture<V> create()
Creates a new SettableFuture in the default state.


set

public boolean set(@Nullable
                   V value)
Sets the value of this future. This method will return true if the value was successfully set, or false if the future has already been set or cancelled.

Overrides:
set in class AbstractFuture<V>
Parameters:
value - the value the future should hold.
Returns:
true if the value was successfully set.

setException

public boolean setException(Throwable throwable)
Sets the future to having failed with the given exception. This exception will be wrapped in an ExecutionException and thrown from the get methods. This method will return true if the exception was successfully set, or false if the future has already been set or cancelled.

Overrides:
setException in class AbstractFuture<V>
Parameters:
throwable - the exception the future should hold.
Returns:
true if the exception was successfully set.


Copyright © 2010-2012. All Rights Reserved.