Package org.apache.ignite.lang
Interface IgniteFuture<V>
-
- Type Parameters:
V
- Type of the result for the future.
- All Known Subinterfaces:
ComputeTaskFuture<R>
,SchedulerFuture<R>
public interface IgniteFuture<V>
Future with simplified exception handling, functional programming support and ability to listen for future completion via functional callback.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
cancel()
Cancels this future.<T> IgniteFuture<T>
chain(IgniteClosure<? super IgniteFuture<V>,T> doneCb)
Make a chained future to convert result of this future (when complete) into a new format.<T> IgniteFuture<T>
chainAsync(IgniteClosure<? super IgniteFuture<V>,T> doneCb, Executor exec)
Make a chained future to convert result of this future (when complete) into a new format.V
get()
Synchronously waits for completion of the computation and returns computation result.V
get(long timeout)
Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.V
get(long timeout, TimeUnit unit)
Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.boolean
isCancelled()
Returnstrue
if this task was cancelled before it completed normally.boolean
isDone()
Returnstrue
if this task completed.void
listen(IgniteInClosure<? super IgniteFuture<V>> lsnr)
Registers a callback to be invoked when the future completes.void
listenAsync(IgniteInClosure<? super IgniteFuture<V>> lsnr, Executor exec)
Registers a callback to be invoked with the specified executor when the future completes.
-
-
-
Method Detail
-
get
V get() throws IgniteException
Synchronously waits for completion of the computation and returns computation result.- Returns:
- Computation result.
- Throws:
IgniteInterruptedException
- Subclass ofIgniteException
thrown if the wait was interrupted.IgniteFutureCancelledException
- Subclass ofIgniteException
thrown if computation was cancelled.IgniteException
- If computation failed.
-
get
V get(long timeout) throws IgniteException
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)
.- Parameters:
timeout
- The maximum time to wait in milliseconds.- Returns:
- Computation result.
- Throws:
IgniteInterruptedException
- Subclass ofIgniteException
thrown if the wait was interrupted.IgniteFutureCancelledException
- Subclass ofIgniteException
thrown if computation was cancelled.IgniteFutureTimeoutException
- Subclass ofIgniteException
thrown if the wait was timed out.IgniteException
- If computation failed.
-
get
V get(long timeout, TimeUnit unit) throws IgniteException
Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.- Parameters:
timeout
- The maximum time to wait.unit
- The time unit of thetimeout
argument.- Returns:
- Computation result.
- Throws:
IgniteInterruptedException
- Subclass ofIgniteException
thrown if the wait was interrupted.IgniteFutureCancelledException
- Subclass ofIgniteException
thrown if computation was cancelled.IgniteFutureTimeoutException
- Subclass ofIgniteException
thrown if the wait was timed out.IgniteException
- If computation failed.
-
cancel
boolean cancel() throws IgniteException
Cancels this future.- Returns:
True
if future was canceled (i.e. was not finished prior to this call).- Throws:
IgniteException
- If cancellation failed.
-
isCancelled
boolean isCancelled()
Returnstrue
if this task was cancelled before it completed normally.- Returns:
true
if this task was cancelled before it completed
-
isDone
boolean isDone()
Returnstrue
if this task completed.Completion may be due to normal termination, an exception, or cancellation - in all of these cases, this method will return
true
.- Returns:
true
if this task completed.
-
listen
void listen(IgniteInClosure<? super IgniteFuture<V>> lsnr)
Registers a callback to be invoked when the future completes. If the future is already completed, callback will be invoked immediately in the current thread.- Parameters:
lsnr
- Listener closure to register. Cannot benull
.
-
listenAsync
void listenAsync(IgniteInClosure<? super IgniteFuture<V>> lsnr, Executor exec)
Registers a callback to be invoked with the specified executor when the future completes.- Parameters:
lsnr
- Listener closure to register. Cannot benull
.exec
- Executor to invoke the listener. Cannot benull
.
-
chain
<T> IgniteFuture<T> chain(IgniteClosure<? super IgniteFuture<V>,T> 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.- Type Parameters:
T
- Type of the converted result.- 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.
-
chainAsync
<T> IgniteFuture<T> chainAsync(IgniteClosure<? super IgniteFuture<V>,T> 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.- Type Parameters:
T
- Type of the converted result.- Parameters:
doneCb
- Done callback that is applied to this future when it finishes to produce chained future result.exec
- Executor to run done callback. Cannot benull
.- Returns:
- Chained future that finishes after this future completes and done callback is called.
-
-