Class GridFinishedFuture<T>
- java.lang.Object
-
- org.apache.ignite.internal.util.future.GridFinishedFuture<T>
-
- All Implemented Interfaces:
IgniteInternalFuture<T>
- Direct Known Subclasses:
GridCacheQueryErrorFuture,GridDhtFinishedFuture,GridNioFinishedFuture
public class GridFinishedFuture<T> extends Object implements IgniteInternalFuture<T>
Future that is completed at creation time.
-
-
Constructor Summary
Constructors Constructor Description GridFinishedFuture()Creates finished future with complete value.GridFinishedFuture(Throwable err)GridFinishedFuture(T t)Creates finished future with complete value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel()Cancels this future.<R> IgniteInternalFuture<R>chain(IgniteClosure<? super IgniteInternalFuture<T>,R> doneCb)Make a chained future to convert result of this future (when complete) into a new format.<T1> IgniteInternalFuture<T1>chain(IgniteClosure<? super IgniteInternalFuture<T>,T1> doneCb, Executor exec)Make a chained future to convert result of this future (when complete) into a new format.<R> IgniteInternalFuture<R>chain(IgniteOutClosure<R> doneCb)Make a chained future to convert result of this future (when complete) into a new format.<R> IgniteInternalFuture<R>chain(IgniteOutClosure<R> doneCb, Executor exec)Make a chained future to convert result of this future (when complete) into a new format.<R> IgniteInternalFuture<R>chainCompose(IgniteClosure<? super IgniteInternalFuture<T>,IgniteInternalFuture<R>> doneCb)Make a chained future that is completed whendoneCbis executed.<R> IgniteInternalFuture<R>chainCompose(IgniteClosure<? super IgniteInternalFuture<T>,IgniteInternalFuture<R>> doneCb, @Nullable Executor exec)Make a chained future that is completed whendoneCbis executed.Throwableerror()Tget()Synchronously waits for completion of the computation and returns computation result.Tget(long timeout)Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.Tget(long timeout, TimeUnit unit)Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.TgetUninterruptibly()Synchronously waits for completion of the computation and returns computation result ignoring interrupts.booleanisCancelled()Returnstrueif this computation was cancelled before it completed normally.booleanisDone()Checks if computation is done.voidlisten(IgniteInClosure<? super IgniteInternalFuture<T>> lsnr)Registers listener closure to be asynchronously notified whenever future completes.voidlisten(IgniteRunnable lsnr)Registers listener closure to be asynchronously notified whenever future completes.Tresult()StringtoString()
-
-
-
Constructor Detail
-
GridFinishedFuture
public GridFinishedFuture()
Creates finished future with complete value.
-
GridFinishedFuture
public GridFinishedFuture(T t)
Creates finished future with complete value.- Parameters:
t- Finished value.
-
GridFinishedFuture
public GridFinishedFuture(Throwable err)
- Parameters:
err- Future error.
-
-
Method Detail
-
error
public Throwable error()
- Specified by:
errorin interfaceIgniteInternalFuture<T>- Returns:
- Error value if future has already been completed with error.
-
result
public T result()
- Specified by:
resultin interfaceIgniteInternalFuture<T>- Returns:
- Result value if future has already been completed normally.
-
cancel
public boolean cancel()
Cancels this future.- Specified by:
cancelin interfaceIgniteInternalFuture<T>- Returns:
Trueif future was canceled (i.e. was not finished prior to this call).
-
isCancelled
public boolean isCancelled()
Returnstrueif this computation was cancelled before it completed normally.- Specified by:
isCancelledin interfaceIgniteInternalFuture<T>- Returns:
Trueif this computation was cancelled before it completed normally.
-
isDone
public boolean isDone()
Checks if computation is done.- Specified by:
isDonein interfaceIgniteInternalFuture<T>- Returns:
Trueif computation is done,falseotherwise.
-
get
public T get() throws IgniteCheckedException
Synchronously waits for completion of the computation and returns computation result.- Specified by:
getin interfaceIgniteInternalFuture<T>- Returns:
- Computation result.
- Throws:
IgniteInterruptedCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was interrupted.IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
get
public T get(long timeout) throws IgniteCheckedException
Synchronously waits for completion of the computation for up to the timeout specified and returns computation result. This method is equivalent to callingget(long, TimeUnit.MILLISECONDS).- Specified by:
getin interfaceIgniteInternalFuture<T>- Parameters:
timeout- The maximum time to wait in milliseconds.- Returns:
- Computation result.
- Throws:
IgniteInterruptedCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was interrupted.IgniteFutureTimeoutCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was timed out.IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
get
public T get(long timeout, TimeUnit unit) throws IgniteCheckedException
Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.- Specified by:
getin interfaceIgniteInternalFuture<T>- Parameters:
timeout- The maximum time to wait.unit- The time unit of thetimeoutargument.- Returns:
- Computation result.
- Throws:
IgniteInterruptedCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was interrupted.IgniteFutureTimeoutCheckedException- Subclass ofIgniteCheckedExceptionthrown if the wait was timed out.IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
getUninterruptibly
public T getUninterruptibly() throws IgniteCheckedException
Synchronously waits for completion of the computation and returns computation result ignoring interrupts.- Specified by:
getUninterruptiblyin interfaceIgniteInternalFuture<T>- Returns:
- Computation result.
- Throws:
IgniteFutureCancelledCheckedException- Subclass ofIgniteCheckedExceptionthrows if computation was cancelled.IgniteCheckedException- If computation failed.
-
listen
public void listen(IgniteInClosure<? super IgniteInternalFuture<T>> lsnr)
Registers listener closure to be asynchronously notified whenever future completes.- Specified by:
listenin interfaceIgniteInternalFuture<T>- Parameters:
lsnr- Listener closure to register.
-
listen
public void listen(IgniteRunnable lsnr)
Registers listener closure to be asynchronously notified whenever future completes.- Specified by:
listenin interfaceIgniteInternalFuture<T>- Parameters:
lsnr- Listener closure to register.
-
chain
public <R> IgniteInternalFuture<R> chain(IgniteClosure<? super IgniteInternalFuture<T>,R> doneCb)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<T>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chain
public <R> IgniteInternalFuture<R> chain(IgniteOutClosure<R> doneCb)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<T>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chain
public <T1> IgniteInternalFuture<T1> chain(IgniteClosure<? super IgniteInternalFuture<T>,T1> doneCb, Executor exec)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<T>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.exec- Executor to run callback.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chain
public <R> IgniteInternalFuture<R> chain(IgniteOutClosure<R> doneCb, Executor exec)
Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainin interfaceIgniteInternalFuture<T>- Parameters:
doneCb- Done callback that is applied to this future when it finishes to produce chained future result.exec- Executor to run callback.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
chainCompose
public <R> IgniteInternalFuture<R> chainCompose(IgniteClosure<? super IgniteInternalFuture<T>,IgniteInternalFuture<R>> doneCb)
Make a chained future that is completed whendoneCbis executed. Callback is called with this future as the argument, when this future completes. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainComposein interfaceIgniteInternalFuture<T>- Type Parameters:
R- Type parameter.- Parameters:
doneCb- Done callback.- Returns:
- Chained future.
-
chainCompose
public <R> IgniteInternalFuture<R> chainCompose(IgniteClosure<? super IgniteInternalFuture<T>,IgniteInternalFuture<R>> doneCb, @Nullable @Nullable Executor exec)
Make a chained future that is completed whendoneCbis executed. Callback is called with this future as the argument, when this future completes. It is guaranteed that done callback will be called only ONCE.- Specified by:
chainComposein interfaceIgniteInternalFuture<T>- Type Parameters:
R- Type parameter.- Parameters:
doneCb- Done callback.exec- Executor to run callback.- Returns:
- Chained future.
-
-