Interface AsyncSupport

All Known Subinterfaces:
JsonRpcClient<T>, JsonRpcTransport<T>, PollingChainTipService, RxJsonChainTipClient, RxJsonRpcClient
All Known Implementing Classes:
BitcoinClient, BitcoinExtendedClient, DefaultRpcClient, EthereumClient, JsonRpcClientHttpUrlConnection, JsonRpcClientJavaNet, NamecoinClient, PollingChainTipServiceImpl, RxBitcoinClient

public interface AsyncSupport
Helper methods for creating asynchronous calls using CompletableFuture. Since the synchronous methods in DefaultRpcClient throw checked exceptions this interface provides wrapper support to make it easier to convert them to async calls.
  • Method Details

    • supplyAsync

      default <T> CompletableFuture<T> supplyAsync(AsyncSupport.ThrowingSupplier<T> throwingSupplier)
      Supply async for a ThrowingSupplier by catching exceptions and completing exceptionally.
      Type Parameters:
      T - return type
      Parameters:
      throwingSupplier - Supplier of T that can throw an IOException
      Returns:
      A completable future, returning T
    • supplyAsync

      default <T> CompletableFuture<T> supplyAsync(AsyncSupport.ThrowingSupplier<T> throwingSupplier, Executor executor)
      Supply async for a ThrowingSupplier by catching exceptions and completing exceptionally.
      Type Parameters:
      T - return type
      Parameters:
      throwingSupplier - Supplier of T that can throw an IOException
      executor - Executor to run the Supplier
      Returns:
      A completable future, returning T
    • getDefaultAsyncExecutor

      Return the default executor for supplying asynchronicity.
      Returns:
      An executor.