Interface Async

All Superinterfaces:
RuntimeType.Api<AsyncConfig>

public interface Async extends RuntimeType.Api<AsyncConfig>
Runs synchronous suppliers asynchronously using virtual threads. Includes convenient static method to avoid creating instances of this class.
  • Method Details

    • create

      static Async create()
      Async with default executor service.
      Returns:
      a default async instance
    • create

      static Async create(AsyncConfig config)
      Async with explicit configuration.
      Parameters:
      config - async configuration
      Returns:
      a default async instance
    • create

      static Async create(Consumer<AsyncConfig.Builder> builderConsumer)
      Create a new Async customizing its configuration.
      Parameters:
      builderConsumer - consumer of async configuration
      Returns:
      a new async
    • builder

      static AsyncConfig.Builder builder()
      Create a new fluent API builder for async.
      Returns:
      a new builder
    • invokeStatic

      static <T> CompletableFuture<T> invokeStatic(Supplier<T> supplier)
      Convenience method to avoid having to call create().
      Type Parameters:
      T - type of returned value
      Parameters:
      supplier - supplier of value (or a method reference)
      Returns:
      a Single that is a "promise" of the future result
    • invokeStatic

      static <T> CompletableFuture<T> invokeStatic(Supplier<T> supplier, CompletableFuture<Async> onStart)
      Convenience method to avoid having to call create(). Also accepts an onStart future to inform of async task startup.
      Type Parameters:
      T - type of returned value
      Parameters:
      supplier - supplier of value (or a method reference)
      onStart - future completed when async task starts
      Returns:
      a future that is a "promise" of the future result
    • invoke

      <T> CompletableFuture<T> invoke(Supplier<T> supplier)
      Invoke a synchronous operation asynchronously. This method never throws an exception. Any exception is returned via the CompletableFuture result.
      Type Parameters:
      T - type of returned value
      Parameters:
      supplier - supplier of value (or a method reference)
      Returns:
      a Single that is a "promise" of the future result