org.apache.ignite.internal.client.impl

## Class GridClientFutureAdapter<R>

- java.lang.Object
- - java.util.concurrent.locks.AbstractOwnableSynchronizer
  - - java.util.concurrent.locks.AbstractQueuedSynchronizer
    - - org.apache.ignite.internal.client.impl.GridClientFutureAdapter<R>

All Implemented Interfaces:
  Serializable, GridClientFuture<R>

    public class GridClientFutureAdapter<R>
    extends AbstractQueuedSynchronizer
    implements GridClientFuture<R>

Future adapter.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer

`AbstractQueuedSynchronizer.ConditionObject`

### Constructor Summary

Constructors
Constructor and Description
`GridClientFutureAdapter()` Creates not-finished future without any result.
`GridClientFutureAdapter(R res)` Creates succeeded finished future with given result.
`GridClientFutureAdapter(Throwable err)` Creates failed finished future with given error.

### Method Summary

Methods
`<T> GridClientFutureAdapter<T>` `chain(GridClientFutureCallback<R,T> cb)` Creates future's chain and completes chained future, when this future finishes.
`R` `get()` Synchronously waits for completion and returns result.
`R` `get(long timeout, TimeUnit unit)` Synchronously waits for completion and returns result.
`boolean` `isDone()` Checks if future is done.
`void` `listen(GridClientFutureListener<R>... lsnrs)` Register new listeners for notification when future completes.
`void` `onDone(R res)` Callback to notify that future is finished successfully.
`void` `onDone(Throwable err)` Callback to notify that future is finished with error.
`protected int` `tryAcquireShared(int ignore)`
`protected boolean` `tryReleaseShared(int ignore)`

### Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer

`acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease`

### Methods inherited from class java.util.concurrent.locks.AbstractOwnableSynchronizer

`getExclusiveOwnerThread, setExclusiveOwnerThread`

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

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

### Constructor Detail

#### GridClientFutureAdapter

    public GridClientFutureAdapter()

Creates not-finished future without any result.

#### GridClientFutureAdapter

    public GridClientFutureAdapter(R res)

Creates succeeded finished future with given result.

Parameters:
  `res` - Future result.

#### GridClientFutureAdapter

    public GridClientFutureAdapter(Throwable err)

Creates failed finished future with given error.

Parameters:
  `err` - Future error.

### Method Detail

#### get

    public R get()
          throws GridClientException

Synchronously waits for completion and returns result.

Specified by:
  `get` in interface `GridClientFuture<R>`
Returns:
  Completed future result.
Throws:
  `GridClientException` - In case of error.

#### get

    public R get(long timeout,
        TimeUnit unit)
          throws GridClientException

Synchronously waits for completion and returns result.

Specified by:
  `get` in interface `GridClientFuture<R>`
Parameters:
  `timeout` - Timeout interval to wait future completes.
  `unit` - Timeout interval unit to wait future completes.
Returns:
  Completed future result.
Throws:
  `GridClientException` - In case of error.
  `GridClientFutureTimeoutException` - If timed out before future finishes.

#### isDone

    public boolean isDone()

Checks if future is done.

Specified by:
  `isDone` in interface `GridClientFuture<R>`
Returns:
  Whether future is done.

#### onDone

    public void onDone(@Nullable
              R res)

Callback to notify that future is finished successfully.

Parameters:
  `res` - Result (can be `null`).

#### onDone

    public void onDone(Throwable err)

Callback to notify that future is finished with error.

Parameters:
  `err` - Error (can't be `null`).

#### tryAcquireShared

    protected final int tryAcquireShared(int ignore)

Overrides:
  `tryAcquireShared` in class `AbstractQueuedSynchronizer`

#### tryReleaseShared

    protected final boolean tryReleaseShared(int ignore)

Overrides:
  `tryReleaseShared` in class `AbstractQueuedSynchronizer`

#### listen

    public void listen(GridClientFutureListener<R>... lsnrs)

Register new listeners for notification when future completes. Note that current implementations are calling listeners in the completing thread.

Specified by:
  `listen` in interface `GridClientFuture<R>`
Parameters:
  `lsnrs` - Listeners to be registered.

#### chain

    public <T> GridClientFutureAdapter<T> chain(GridClientFutureCallback<R,T> cb)

Creates future's chain and completes chained future, when this future finishes.

Type Parameters:
  `T` - New future format to convert this finished future to.
Parameters:
  `cb` - Future callback to convert this future result into expected format.
Returns:
  Chained future with new format.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015