com.levigo.util.concurrent
Class PrecompletedFuture<V>

java.lang.Object
  extended by com.levigo.util.concurrent.PrecompletedFuture<V>
Type Parameters:
V - the value type
All Implemented Interfaces:
Future<V>

public class PrecompletedFuture<V>
extends Object
implements Future<V>

An implementation of Future which is already completed at the time of creation.


Constructor Summary
PrecompletedFuture(Throwable throwable)
          Create a pre-completed future for a failed operation which will throw the given Throwable (wrapped in an ExecutionException) upon calling get().
PrecompletedFuture(V value)
          Create a pre-completed future with the given result value.
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
           
 V get()
           
 V get(long timeout, TimeUnit unit)
           
 boolean isCancelled()
           
 boolean isDone()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrecompletedFuture

public PrecompletedFuture(V value)
Create a pre-completed future with the given result value.

Parameters:
value -

PrecompletedFuture

public PrecompletedFuture(Throwable throwable)
Create a pre-completed future for a failed operation which will throw the given Throwable (wrapped in an ExecutionException) upon calling get().

Parameters:
throwable -
Method Detail

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface Future<V>

get

public V get()
      throws ExecutionException
Specified by:
get in interface Future<V>
Throws:
ExecutionException

get

public V get(long timeout,
             TimeUnit unit)
      throws ExecutionException
Specified by:
get in interface Future<V>
Throws:
ExecutionException

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface Future<V>

isDone

public boolean isDone()
Specified by:
isDone in interface Future<V>


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.