com.atlassian.util.concurrent
Class SettableFuture<T>

java.lang.Object
  extended by com.atlassian.util.concurrent.SettableFuture<T>
All Implemented Interfaces:
java.util.concurrent.Future<T>

@ThreadSafe
public class SettableFuture<T>
extends java.lang.Object
implements java.util.concurrent.Future<T>

SettableFuture is a Future implementation where the responsibility for producing the result is external to the future instance, unlike FutureTask where the future holds the operation (a Callable or Runnable instance) and the first thread that calls FutureTask.run() executes the operation.

This is useful in situations where all the inputs may not be available at construction time.

This class does not support cancellation.


Constructor Summary
SettableFuture()
           
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
           
 T get()
           
 T get(long timeout, java.util.concurrent.TimeUnit unit)
           
 boolean isCancelled()
           
 boolean isDone()
           
 void set(T value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SettableFuture

public SettableFuture()
Method Detail

set

public void set(T value)

get

public T get()
      throws java.lang.InterruptedException
Specified by:
get in interface java.util.concurrent.Future<T>
Throws:
java.lang.InterruptedException

get

public T get(long timeout,
             java.util.concurrent.TimeUnit unit)
      throws java.lang.InterruptedException,
             java.util.concurrent.TimeoutException
Specified by:
get in interface java.util.concurrent.Future<T>
Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException

isDone

public boolean isDone()
Specified by:
isDone in interface java.util.concurrent.Future<T>

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface java.util.concurrent.Future<T>

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface java.util.concurrent.Future<T>


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.