public class NotifyingFutureImpl<T> extends BaseNotifyingFuture<T> implements NotifyingNotifiableFuture<T>
NotifyingFuture
.
Typical usage:
Object retval = .... // do some work here NotifyingFuture nf = new NotifyingFutureImpl();
rpcManager.broadcastRpcCommandInFuture(nf, command); return nf;
Modifier and Type | Field and Description |
---|---|
private T |
actualReturnValue |
private java.lang.Throwable |
exceptionThrown |
private java.util.concurrent.Future<T> |
future |
private java.util.concurrent.CountDownLatch |
latch |
callCompleted, listenerLock, listeners
Constructor and Description |
---|
NotifyingFutureImpl() |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
java.util.concurrent.Future<T> |
getFuture() |
boolean |
isCancelled() |
boolean |
isDone() |
void |
notifyDone(T result)
Notify the listeners that the operation has finished.
|
void |
notifyException(java.lang.Throwable exception)
Notify the listeners that the operation has finished.
|
void |
setFuture(java.util.concurrent.Future<T> future)
Setup the future which is wrapped by implementation of this interface.
|
attachListener, fireListeners
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
attachListener
private T actualReturnValue
private java.lang.Throwable exceptionThrown
private volatile java.util.concurrent.Future<T> future
private final java.util.concurrent.CountDownLatch latch
public void setFuture(java.util.concurrent.Future<T> future)
NotifyingNotifiableFuture
setFuture
in interface NotifyingNotifiableFuture<T>
public java.util.concurrent.Future<T> getFuture() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<T>
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<T>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<T>
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public void notifyDone(T result)
NotifyingNotifiableFuture
notifyDone
in interface NotifyingNotifiableFuture<T>
public void notifyException(java.lang.Throwable exception)
NotifyingNotifiableFuture
notifyException
in interface NotifyingNotifiableFuture<T>