org.apache.ignite.internal

## Class AsyncSupportAdapter<T extends IgniteAsyncSupport>

- java.lang.Object
- - org.apache.ignite.internal.AsyncSupportAdapter<T>

All Implemented Interfaces:
  IgniteAsyncSupport

Direct Known Subclasses:
  GatewayProtectedCacheProxy, IgfsAsyncImpl, IgniteCacheProxyImpl, IgniteClusterAsyncImpl, IgniteComputeImpl, IgniteEventsImpl, IgniteMessagingImpl, IgniteServicesImpl

    public class AsyncSupportAdapter<T extends IgniteAsyncSupport>
    extends Object
    implements IgniteAsyncSupport

Adapter for `IgniteAsyncSupport`.

### Field Summary

Fields
`protected ThreadLocal<IgniteFuture<?>>` `curFut` Future for previous asynchronous operation.

### Constructor Summary

Constructors
Constructor and Description
`AsyncSupportAdapter()` Default constructor.
`AsyncSupportAdapter(boolean async)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected T` `createAsyncInstance()` Creates component with asynchronous mode enabled.
`protected <R> IgniteFuture<R>` `createFuture(IgniteInternalFuture<R> fut)`
`<R> IgniteFuture<R>` `future()` Gets and resets future for previous asynchronous operation.
`<R> IgniteFuture<R>` `future(boolean reset)` Gets and optionally resets future for previous asynchronous operation.
`boolean` `isAsync()`
`<R> R` `saveOrGet(IgniteInternalFuture<R> fut)`
`T` `withAsync()` Gets instance of this component with asynchronous mode enabled.

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

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

### Field Detail

#### curFut

    protected ThreadLocal<IgniteFuture<?>> curFut

Future for previous asynchronous operation.

### Constructor Detail

#### AsyncSupportAdapter

    public AsyncSupportAdapter()

Default constructor.

#### AsyncSupportAdapter

    public AsyncSupportAdapter(boolean async)

Parameters:
  `async` - Async enabled flag.

### Method Detail

#### withAsync

    public T withAsync()

Gets instance of this component with asynchronous mode enabled.

Specified by:
  `withAsync` in interface `IgniteAsyncSupport`
Returns:
  Instance of this component with asynchronous mode enabled.

#### createAsyncInstance

    protected T createAsyncInstance()

Creates component with asynchronous mode enabled.

Returns:
  Component with asynchronous mode enabled.

#### isAsync

    public boolean isAsync()

Specified by:
  `isAsync` in interface `IgniteAsyncSupport`
Returns:
  `True` if asynchronous mode is enabled.

#### future

    public <R> IgniteFuture<R> future()

Gets and resets future for previous asynchronous operation.

Specified by:
  `future` in interface `IgniteAsyncSupport`
Returns:
  Future for previous asynchronous operation.

#### future

    public <R> IgniteFuture<R> future(boolean reset)

Gets and optionally resets future for previous asynchronous operation.

Parameters:
  `reset` - Specifies whether to reset future.
Returns:
  Future for previous asynchronous operation.

#### saveOrGet

    public <R> R saveOrGet(IgniteInternalFuture<R> fut)
                    throws IgniteCheckedException

Parameters:
  `fut` - Future.
Returns:
  If async mode is enabled saves future and returns `null`, otherwise waits for future and returns result.
Throws:
  `IgniteCheckedException` - If asynchronous mode is disabled and future failed.

#### createFuture

    protected <R> IgniteFuture<R> createFuture(IgniteInternalFuture<R> fut)

Parameters:
  `fut` - Internal future.
Returns:
  Public API future.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

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