V
- the result type of the object returned when the operation completes.public class FutureImpl<V>
extends java.lang.Object
implements com.scaleoutsoftware.soss.client.da.ListenableFuture<V>
Constructor and Description |
---|
FutureImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(com.scaleoutsoftware.soss.client.da.FutureListener<V> listener) |
boolean |
cancel(boolean mayInterruptIfRunning) |
V |
get() |
V |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
void |
removeListener(com.scaleoutsoftware.soss.client.da.FutureListener<V> listener) |
void |
setComplete(V value)
Indicate that the operation has successfully completed.
|
boolean |
setCompleteIfActive(V value)
If the operation has not yet finished, indicate that the operation has successfully
completed.
|
void |
setException(java.lang.Throwable cause)
Indicate that the operation was unsuccessfully completed.
|
boolean |
setExceptionIfActive(java.lang.Throwable cause)
If the operation has not yet finished, indicate that the operation has failed.
|
void |
setThread(java.lang.Thread threadExecutingOperation)
Record the
Thread executing the operation so that we know which thread to
interrupt if the cancel(boolean) method is called. |
boolean |
setThreadIfActive(java.lang.Thread threadExecutingOperation)
If the operation is not yet finished, record the
Thread executing the operation
so that we know which thread to interrupt if the cancel(boolean) method is
called. |
public void setThread(java.lang.Thread threadExecutingOperation)
Record the Thread
executing the operation so that we know which thread to
interrupt if the cancel(boolean)
method is called. If not set, no thread will
be interrupted if the operation is cancelled and the operation will continue even after
waiters are released.
threadExecutingOperation
- the thread that is executing the requested operation: the thread that will be
interrupted if a cancel(boolean)
is requested.java.lang.IllegalStateException
- if the operation is no longer pending.setThreadIfActive(Thread)
public boolean setThreadIfActive(java.lang.Thread threadExecutingOperation)
If the operation is not yet finished, record the Thread
executing the operation
so that we know which thread to interrupt if the cancel(boolean)
method is
called. If not set, no thread will be interrupted if the operation is cancelled and the
operation will continue even after waiters are released.
threadExecutingOperation
- the thread that is executing the requested operation: the thread that will be
interrupted if a cancel(boolean)
is requested.true
if this invocation successfully set the thread.
false
if the operation was already complete.setThread(Thread)
public void setComplete(V value)
Future
's
return value and release any threads waiting for the operation to complete.value
- the result to be returned via get()
.setCompleteIfActive(Object)
public boolean setCompleteIfActive(V value)
If the operation has not yet finished, indicate that the operation has successfully
completed. Set this Future
's return value and release any threads waiting for
the operation to complete.
value
- the result to be returned via get()
.true
if this invocation caused the future to become "done".
false
otherwise.setComplete(Object)
public void setException(java.lang.Throwable cause)
get()
is called, an instance of
ExecutionException
with a cause set to cause will be thrown.cause
- the cause of the operation's failure.java.lang.IllegalStateException
- if the operation was already complete.setExceptionIfActive(Throwable)
public boolean setExceptionIfActive(java.lang.Throwable cause)
If the operation has not yet finished, indicate that the operation has failed. Establish
cause as the reason for the operation's failure. When get()
is called, an
instance of ExecutionException
with a cause set to cause will be thrown.
cause
- the cause of the operation's failure.true
if this invocation caused the future to become "done".
false
otherwise.setException(Throwable)
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<V>
public V get() throws java.lang.InterruptedException, java.util.concurrent.CancellationException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<V>
java.lang.InterruptedException
java.util.concurrent.CancellationException
java.util.concurrent.ExecutionException
public V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.CancellationException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<V>
java.lang.InterruptedException
java.util.concurrent.CancellationException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<V>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<V>
public void addListener(com.scaleoutsoftware.soss.client.da.FutureListener<V> listener)
addListener
in interface com.scaleoutsoftware.soss.client.da.ListenableFuture<V>