org.apache.ignite.internal.util.future

## Class IgniteFutureImpl<V>

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

All Implemented Interfaces:
  Future<V>, IgniteFuture<V>

Direct Known Subclasses:
  IgniteFinishedFutureImpl, IgniteFinishedFutureImplEx

    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

Methods
`boolean` `cancel()` Cancels this future.
`boolean` `cancel(boolean mayInterruptIfRunning)`
`<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.
`boolean` `concurrentNotify()` Gets value concurrent listener notification flag.
`void` `concurrentNotify(boolean concurNotify)` Flag to turn on or off concurrent listener notification.
`long` `duration()` Gets duration in milliseconds between start of the future and current time if future is not finished, or between start and finish of this future.
`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()`
`boolean` `isDone()`
`void` `listenAsync(IgniteInClosure<? super IgniteFuture<V>> lsnr)` Registers listener closure to be asynchronously notified whenever future completes.
`long` `startTime()` Gets start time for this future.
`void` `stopListenAsync(IgniteInClosure<? super IgniteFuture<V>> lsnr)` Removes given listener from the future.
`boolean` `syncNotify()` Gets value of synchronous listener notification flag.
`void` `syncNotify(boolean syncNotify)` Flag to turn on or off synchronous listener notification.
`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.

#### startTime

    public long startTime()

Gets start time for this future.

Specified by:
  `startTime` in interface `IgniteFuture<V>`
Returns:
  Start time for this future.

#### duration

    public long duration()

Gets duration in milliseconds between start of the future and current time if future is not finished, or between start and finish of this future.

Specified by:
  `duration` in interface `IgniteFuture<V>`
Returns:
  Time in milliseconds this future has taken to execute.

#### syncNotify

    public void syncNotify(boolean syncNotify)

Flag to turn on or off synchronous listener notification. If this flag is `true`, then upon future completion the notification may happen in the same thread that created the future. This becomes especially important when adding listener to a future that is already `done` - if this flag is `true`, then listener will be immediately notified within the same thread.

Default value is `false`. To change the default, set `IgniteSystemProperties.IGNITE_FUT_SYNC_NOTIFICATION` system property to `true`.

Specified by:
  `syncNotify` in interface `IgniteFuture<V>`
Parameters:
  `syncNotify` - Flag to turn on or off synchronous listener notification.

#### syncNotify

    public boolean syncNotify()

Gets value of synchronous listener notification flag. If this flag is `true`, then upon future completion the notification may happen in the same thread that created the future. This becomes especially important when adding listener to a future that is already `done` - if this flag is `true`, then listener will be immediately notified within the same thread.

Default value is `false`. To change the default, set `IgniteSystemProperties.IGNITE_FUT_SYNC_NOTIFICATION` system property to `true`.

Specified by:
  `syncNotify` in interface `IgniteFuture<V>`
Returns:
  Synchronous listener notification flag.

#### concurrentNotify

    public void concurrentNotify(boolean concurNotify)

Flag to turn on or off concurrent listener notification. This flag comes into play only when a future has more than one listener subscribed to it. If this flag is `true`, then all listeners will be notified concurrently by different threads; otherwise, listeners will be notified one after another within one thread (depending on `IgniteFuture.syncNotify()` flag, these notifications may happen either in the same thread which started the future, or in a different thread).

Default value is `false`. To change the default, set `IgniteSystemProperties.IGNITE_FUT_CONCURRENT_NOTIFICATION` system property to `true`.

Specified by:
  `concurrentNotify` in interface `IgniteFuture<V>`
Parameters:
  `concurNotify` - Flag to turn on or off concurrent listener notification.

#### concurrentNotify

    public boolean concurrentNotify()

Gets value concurrent listener notification flag. This flag comes into play only when a future has more than one listener subscribed to it. If this flag is `true`, then all listeners will be notified concurrently by different threads; otherwise, listeners will be notified one after another within one thread (depending on `IgniteFuture.syncNotify()` flag, these notifications may happen either in the same thread which started the future, or in a different thread).

Default value is `false`. To change the default, set `IgniteSystemProperties.IGNITE_FUT_CONCURRENT_NOTIFICATION` system property to `true`.

Specified by:
  `concurrentNotify` in interface `IgniteFuture<V>`
Returns:
  Concurrent listener notification flag

#### isCancelled

    public boolean isCancelled()

Specified by:
  `isCancelled` in interface `Future<V>`

#### isDone

    public boolean isDone()

Specified by:
  `isDone` in interface `Future<V>`

#### listenAsync

    public void listenAsync(@Nullable
                   IgniteInClosure<? super IgniteFuture<V>> lsnr)

Registers listener closure to be asynchronously notified whenever future completes.

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

#### stopListenAsync

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

Removes given listener from the future.

Specified by:
  `stopListenAsync` in interface `IgniteFuture<V>`
Parameters:
  `lsnr` - Listener to remove.

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

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

#### cancel

    public boolean cancel(boolean mayInterruptIfRunning)

Specified by:
  `cancel` in interface `Future<V>`

#### get

    public V get()

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

Specified by:
  `get` in interface `Future<V>`
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 `Future<V>`
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.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

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