public class SingleOperationFuture<ResultType> extends AbstractFuture<ResultType>
Future implementation for a single operation.
Subclasses may be created if desired. Note that if subclasses are created, that they should/must be very careful with respect to overriding the synchronized methods in this class.
| Modifier and Type | Field and Description |
|---|---|
protected IProgressMonitor |
progressMonitor |
| Constructor and Description |
|---|
SingleOperationFuture() |
SingleOperationFuture(IProgressMonitor progressMonitor) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel()
Cancel the operation
|
ResultType |
get()
Waits if necessary for one or more operations to complete, and then
returns result(s).
|
ResultType |
get(long waitTimeInMillis)
Waits if necessary for one or more operations to complete, and then
returns result(s).
|
IProgressMonitor |
getProgressMonitor()
Return a progress monitor for this future.
|
IStatus |
getStatus()
Get status for operation.
|
boolean |
hasValue()
Returns true if any underlying operation(s) have
completed.
|
boolean |
isCanceled()
Returns
true if this future has been previously canceled,
false otherwise. |
boolean |
isDone()
Returns true if all underlying operation(s) have been
completed.
|
void |
runWithProgress(IProgressRunnable<?> runnable)
This method is not intended to be called by clients.
|
protected void |
set(ResultType newValue) |
protected void |
setException(java.lang.Throwable ex) |
public SingleOperationFuture()
public SingleOperationFuture(IProgressMonitor progressMonitor)
public ResultType get() throws java.lang.InterruptedException, OperationCanceledException
IFuturejava.lang.InterruptedException - if thread calling this method is interrupted.OperationCanceledException - if the operation has been canceled via progress monitor
#getProgressMonitor().public ResultType get(long waitTimeInMillis) throws java.lang.InterruptedException, TimeoutException, OperationCanceledException
IFuturewaitTimeInMillis - the maximum time to wait in milliseconds for the operation(s)
to complete.java.lang.InterruptedException - if thread calling this method is interrupted.TimeoutException - if the given wait time is exceeded without getting result.OperationCanceledException - if the operation has been canceled via progress monitor
#getProgressMonitor().public boolean isDone()
IFutureReturns true if all underlying operation(s) have been completed.
If this future represents access to just one operation, then this method
and IFuture.hasValue() will always return the same value. That is, when
a single operation has a value, it is then considered done/completed and
both IFuture.hasValue() and #isDone will return true.
If this future represents multiple operations, then this method will only
return true when all of the operations have
completed. Until all operations have completed, it will return
false.
Completion can be due to normal operation completion, an exception, or user cancellation -- in all of these cases, this method will return true if all underlying operation(s) have been completed.
public void runWithProgress(IProgressRunnable<?> runnable)
IExecutors.public IStatus getStatus()
IFuture
Get status for operation. Will return null until at least
one operation(s) are complete.
If IFuture.hasValue() returns true, this method will return
a non-null IStatus. If IFuture.hasValue() returns
false, this method will return null.
Note that the returned IStatus instance may be an IMultiStatus, meaning that multiple operations have completed or are pending completion.
null if IFuture.hasValue() returns
false.IFuture.hasValue()public boolean hasValue()
IFutureReturns true if any underlying operation(s) have completed.
If this future represents access to just one operation, then this method
and IFuture.isDone() will always return the same value. That is, when a
single operation has a value, it is then considered done/completed and
both IFuture.isDone() and this method will return true.
If this future represents multiple operations, then this method will
return true when any of the operations have
completed. Until the first operation is completed, it will return
false.
public boolean cancel()
IFutureprotected void setException(java.lang.Throwable ex)
protected void set(ResultType newValue)
public IProgressMonitor getProgressMonitor()
AbstractFuturegetProgressMonitor in class AbstractFuture<ResultType>public boolean isCanceled()
AbstractFuturetrue if this future has been previously canceled,
false otherwise. Subclasses must override.isCanceled in class AbstractFuture<ResultType>true if this future has been previously canceled,
false otherwise