org.apache.ignite.internal.util.future

## Class IgniteFutureImpl<V>

- java.lang.Object
- - org.apache.ignite.internal.util.future.IgniteFutureImpl<V>

All Implemented Interfaces:
  IgniteFuture<V>

Direct Known Subclasses:
  IgniteCacheFutureImpl, IgniteFinishedFutureImpl

    public class IgniteFutureImpl<V>
    extends Object
    implements IgniteFuture<V>

Implementation of public API future.

### Field Summary

Fields
`protected IgniteInternalFuture<V>` `fut`

### Constructor Summary

Constructors
Constructor and Description
`IgniteFutureImpl(IgniteInternalFuture<V> fut)`

### Method Summary

All Methods Instance Methods Concrete Methods
`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.
`protected <T> IgniteInternalFuture<T>` `chainInternal(IgniteClosure<? super IgniteFuture<V>,T> doneCb, @Nullable Executor exec)`
`protected RuntimeException` `convertException(IgniteCheckedException e)` Convert internal exception to public exception.
`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.
`IgniteInternalFuture<V>` `internalFuture()`
`boolean` `isCancelled()` Returns `true` if this task was cancelled before it completed normally.
`boolean` `isDone()` Returns `true` if this task completed.
`void` `listen(IgniteInClosure<? super IgniteFuture<V>> lsnr)` Registers listener closure to be asynchronously notified whenever future completes.
`void` `listenAsync(IgniteInClosure<? super IgniteFuture<V>> lsnr, Executor exec)` Registers listener closure to be asynchronously notified whenever future completes.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### fut

    protected final IgniteInternalFuture<V> fut

### Constructor Detail

#### IgniteFutureImpl

    public IgniteFutureImpl(IgniteInternalFuture<V> fut)

Parameters:
  `fut` - Future.

### Method Detail

#### internalFuture

    public IgniteInternalFuture<V> internalFuture()

Returns:
  Internal future.

#### isCancelled

    public boolean isCancelled()

Returns `true` if this task was cancelled before it completed normally.

Specified by:
  `isCancelled` in interface `IgniteFuture<V>`
Returns:
  `true` if this task was cancelled before it completed

#### isDone

    public boolean isDone()

Returns `true` 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`.

Specified by:
  `isDone` in interface `IgniteFuture<V>`
Returns:
  `true` if this task completed.

#### listen

    public void listen(IgniteInClosure<? super IgniteFuture<V>> lsnr)

Registers listener closure to be asynchronously notified whenever future completes. Closure will be processed in thread that completes this future or (if future already completed) immediately in current thread.

Specified by:
  `listen` in interface `IgniteFuture<V>`
Parameters:
  `lsnr` - Listener closure to register. Cannot be `null`.

#### listenAsync

    public void listenAsync(IgniteInClosure<? super IgniteFuture<V>> lsnr,
                            Executor exec)

Registers listener closure to be asynchronously notified whenever future completes. Closure will be processed in specified executor.

Specified by:
  `listenAsync` in interface `IgniteFuture<V>`
Parameters:
  `lsnr` - Listener closure to register. Cannot be `null`.
  `exec` - Executor to run listener. Cannot be `null`.

#### chain

    public <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.

Specified by:
  `chain` in interface `IgniteFuture<V>`
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

    public <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.

Specified by:
  `chainAsync` in interface `IgniteFuture<V>`
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 be `null`.
Returns:
  Chained future that finishes after this future completes and done callback is called.

#### chainInternal

    protected <T> IgniteInternalFuture<T> chainInternal(IgniteClosure<? super IgniteFuture<V>,T> doneCb,
                                                        @Nullable
                                                        @Nullable Executor exec)

Parameters:
  `doneCb` - Done callback.
Returns:
  Internal future

#### cancel

    public boolean cancel()
                   throws IgniteException

Cancels this future.

Specified by:
  `cancel` in interface `IgniteFuture<V>`
Returns:
  `True` if future was canceled (i.e. was not finished prior to this call).
Throws:
  `IgniteException` - If cancellation failed.

#### get

    public V get()

Synchronously waits for completion of the computation and returns computation result.

Specified by:
  `get` in interface `IgniteFuture<V>`
Returns:
  Computation result.

#### get

    public V get(long timeout)

Synchronously waits for completion of the computation for up to the timeout specified and returns computation result. This method is equivalent to calling `get(long, TimeUnit.MILLISECONDS)`.

Specified by:
  `get` in interface `IgniteFuture<V>`
Parameters:
  `timeout` - The maximum time to wait in milliseconds.
Returns:
  Computation result.

#### get

    public V get(long timeout,
                 TimeUnit unit)

Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.

Specified by:
  `get` in interface `IgniteFuture<V>`
Parameters:
  `timeout` - The maximum time to wait.
  `unit` - The time unit of the `timeout` argument.
Returns:
  Computation result.

#### convertException

    protected RuntimeException convertException(IgniteCheckedException e)

Convert internal exception to public exception.

Parameters:
  `e` - Internal exception.
Returns:
  Public excpetion.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.0
Release Date | : February 27 2020