org.apache.ignite.internal.util.nio

## Class GridNioFinishedFuture<R>

- java.lang.Object
- - org.apache.ignite.internal.util.nio.GridNioFinishedFuture<R>

All Implemented Interfaces:
  GridNioFuture<R>

    public class GridNioFinishedFuture<R>
    extends Object
    implements GridNioFuture<R>

Future that represents already completed result.

### Constructor Summary

Constructors
Constructor and Description
`GridNioFinishedFuture(R res)` Constructs a future which `get()` method will return a given result.
`GridNioFinishedFuture(Throwable err)` Constructs a future which `get()` method will throw given exception.

### Method Summary

Methods
`boolean` `cancel()` Cancels this future.
`R` `get()` Synchronously waits for completion of the operation and returns operation result.
`R` `get(long timeout)` Synchronously waits for completion of the operation for up to the timeout specified and returns operation result.
`R` `get(long timeout, TimeUnit unit)` Synchronously waits for completion of the operation for up to the timeout specified and returns operation result.
`boolean` `isCancelled()` Returns `true` if this operation was cancelled before it completed normally.
`boolean` `isDone()` Checks if operation is done.
`void` `listenAsync(IgniteInClosure<? super GridNioFuture<R>> lsnr)` Registers listener closure to be asynchronously notified whenever future completes.
`boolean` `messageThread()`
`void` `messageThread(boolean msgThread)` Sets flag indicating that message send future was created in thread that was processing a message.
`boolean` `skipRecovery()`

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

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

### Constructor Detail

#### GridNioFinishedFuture

    public GridNioFinishedFuture(R res)

Constructs a future which `get()` method will return a given result.

Parameters:
  `res` - Future result.

#### GridNioFinishedFuture

    public GridNioFinishedFuture(@Nullable
                         Throwable err)

Constructs a future which `get()` method will throw given exception.

Parameters:
  `err` - Exception to be thrown.

### Method Detail

#### get

    public R get()
          throws IOException,
                 IgniteCheckedException

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

Specified by:
  `get` in interface `GridNioFuture<R>`
Returns:
  Operation result.
Throws:
  `IOException` - If IOException occurred while performing operation.
  `IgniteInterruptedCheckedException` - Subclass of `IgniteCheckedException` thrown if the wait was interrupted.
  `IgniteFutureCancelledCheckedException` - Subclass of `IgniteCheckedException` throws if operation was cancelled.
  `IgniteCheckedException` - If operation failed.

#### get

    public R get(long timeout)
          throws IOException,
                 IgniteCheckedException

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

Specified by:
  `get` in interface `GridNioFuture<R>`
Parameters:
  `timeout` - The maximum time to wait in milliseconds.
Returns:
  Operation result.
Throws:
  `IOException` - If IOException occurred while performing operation.
  `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 operation was cancelled.
  `IgniteCheckedException` - If operation failed.

#### get

    public R get(long timeout,
        TimeUnit unit)
          throws IOException,
                 IgniteCheckedException

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

Specified by:
  `get` in interface `GridNioFuture<R>`
Parameters:
  `timeout` - The maximum time to wait.
  `unit` - The time unit of the `timeout` argument.
Returns:
  Operation result.
Throws:
  `IOException` - If IOException occurred while performing operation.
  `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 operation was cancelled.
  `IgniteCheckedException` - If operation failed.

#### cancel

    public boolean cancel()
                   throws IgniteCheckedException

Cancels this future.

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

#### isDone

    public boolean isDone()

Checks if operation is done.

Specified by:
  `isDone` in interface `GridNioFuture<R>`
Returns:
  `True` if operation is done, `false` otherwise.

#### isCancelled

    public boolean isCancelled()

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

Specified by:
  `isCancelled` in interface `GridNioFuture<R>`
Returns:
  `True` if this operation was cancelled before it completed normally.

#### listenAsync

    public void listenAsync(@Nullable
                   IgniteInClosure<? super GridNioFuture<R>> lsnr)

Registers listener closure to be asynchronously notified whenever future completes.

Specified by:
  `listenAsync` in interface `GridNioFuture<R>`
Parameters:
  `lsnr` - Listener closure to register. If not provided - this method is no-op.

#### messageThread

    public void messageThread(boolean msgThread)

Sets flag indicating that message send future was created in thread that was processing a message.

Specified by:
  `messageThread` in interface `GridNioFuture<R>`
Parameters:
  `msgThread` - `True` if future was created in thread that is processing message.

#### messageThread

    public boolean messageThread()

Specified by:
  `messageThread` in interface `GridNioFuture<R>`
Returns:
  `True` if future was created in thread that was processing message.

#### skipRecovery

    public boolean skipRecovery()

Specified by:
  `skipRecovery` in interface `GridNioFuture<R>`
Returns:
  `True` if skip recovery for this operation.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015