Package one.nio.async
Class SettableFuture<V>
- java.lang.Object
-
- one.nio.async.SettableFuture<V>
-
- All Implemented Interfaces:
java.lang.Runnable,java.util.concurrent.Future<V>,java.util.concurrent.RunnableFuture<V>
public class SettableFuture<V> extends java.lang.Object implements java.util.concurrent.RunnableFuture<V>
-
-
Constructor Summary
Constructors Constructor Description SettableFuture()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)Vget()Vget(long timeout, java.util.concurrent.TimeUnit unit)booleanisCancelled()booleanisDone()voidrun()voidset(V value)voidsetException(java.lang.Throwable throwable)protected voidwaitForCompletion()protected voidwaitForCompletion(long timeout)
-
-
-
Field Detail
-
value
protected V value
-
throwable
protected java.lang.Throwable throwable
-
done
protected volatile boolean done
-
-
Method Detail
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancelin interfacejava.util.concurrent.Future<V>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<V>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<V>
-
get
public V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
get
public V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
set
public void set(V value)
-
setException
public void setException(java.lang.Throwable throwable)
-
waitForCompletion
protected void waitForCompletion() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
waitForCompletion
protected void waitForCompletion(long timeout) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Specified by:
runin interfacejava.util.concurrent.RunnableFuture<V>
-
-