org.apache.ignite.internal.util.future

## 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 and Description
`GridFinishedFuture()` Creates finished future with complete value.
`GridFinishedFuture(T t)` Creates finished future with complete value.
`GridFinishedFuture(Throwable err)`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `cancel()` 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.
`Throwable` `error()`
`T` `get()` Synchronously waits for completion of the computation and returns computation result.
`T` `get(long timeout)` Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.
`T` `get(long timeout, TimeUnit unit)` Synchronously waits for completion of the computation for up to the timeout specified and returns computation result.
`T` `getUninterruptibly()` Synchronously waits for completion of the computation and returns computation result ignoring interrupts.
`boolean` `isCancelled()` Returns `true` if this computation was cancelled before it completed normally.
`boolean` `isDone()` Checks if computation is done.
`void` `listen(IgniteInClosure<? super IgniteInternalFuture<T>> lsnr)` Registers listener closure to be asynchronously notified whenever future completes.
`T` `result()`
`String` `toString()`

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

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

### 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:
  `error` in interface `IgniteInternalFuture<T>`
Returns:
  Error value if future has already been completed with error.

#### result

    public T result()

Specified by:
  `result` in interface `IgniteInternalFuture<T>`
Returns:
  Result value if future has already been completed normally.

#### cancel

    public boolean cancel()

Cancels this future.

Specified by:
  `cancel` in interface `IgniteInternalFuture<T>`
Returns:
  `True` if future was canceled (i.e. was not finished prior to this call).

#### isCancelled

    public boolean isCancelled()

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

Specified by:
  `isCancelled` in interface `IgniteInternalFuture<T>`
Returns:
  `True` if this computation was cancelled before it completed normally.

#### isDone

    public boolean isDone()

Checks if computation is done.

Specified by:
  `isDone` in interface `IgniteInternalFuture<T>`
Returns:
  `True` if computation is done, `false` otherwise.

#### get

    public T get()
          throws IgniteCheckedException

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

Specified by:
  `get` in interface `IgniteInternalFuture<T>`
Returns:
  Computation result.
Throws:
  `IgniteInterruptedCheckedException` - Subclass of `IgniteCheckedException` thrown if the wait was interrupted.
  `IgniteFutureCancelledCheckedException` - Subclass of `IgniteCheckedException` throws 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 calling `get(long, TimeUnit.MILLISECONDS)`.

Specified by:
  `get` in interface `IgniteInternalFuture<T>`
Parameters:
  `timeout` - The maximum time to wait in milliseconds.
Returns:
  Computation result.
Throws:
  `IgniteInterruptedCheckedException` - Subclass of `IgniteCheckedException` thrown if the wait was interrupted.
  `IgniteFutureTimeoutCheckedException` - Subclass of `IgniteCheckedException` thrown if the wait was timed out.
  `IgniteFutureCancelledCheckedException` - Subclass of `IgniteCheckedException` throws 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:
  `get` in interface `IgniteInternalFuture<T>`
Parameters:
  `timeout` - The maximum time to wait.
  `unit` - The time unit of the `timeout` argument.
Returns:
  Computation result.
Throws:
  `IgniteInterruptedCheckedException` - Subclass of `IgniteCheckedException` thrown if the wait was interrupted.
  `IgniteFutureTimeoutCheckedException` - Subclass of `IgniteCheckedException` thrown if the wait was timed out.
  `IgniteFutureCancelledCheckedException` - Subclass of `IgniteCheckedException` throws 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:
  `getUninterruptibly` in interface `IgniteInternalFuture<T>`
Returns:
  Computation result.
Throws:
  `IgniteFutureCancelledCheckedException` - Subclass of `IgniteCheckedException` throws 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:
  `listen` in interface `IgniteInternalFuture<T>`
Parameters:
  `lsnr` - Listener closure to register. If not provided - this method is no-op.

#### 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:
  `chain` in interface `IgniteInternalFuture<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:
  `chain` in interface `IgniteInternalFuture<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.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022