Class AsyncHelper

java.lang.Object
csw.database.javadsl.AsyncHelper

public class AsyncHelper extends Object
A java helper to schedule and execute blocking operations on a dedicated thread pool. This mechanism will prevent any blocking operation to be scheduled on a thread pool designated for async operations.
  • Constructor Details

    • AsyncHelper

      public AsyncHelper()
  • Method Details

    • managedBlock

      public static <T> CompletableFuture<T> managedBlock(Supplier<T> supplier)
      The method wraps ForkJoinPool#managedBlock() and executes the provided supplier in a dedicated thread pool for blocking operations

      Parameters:
      supplier - to be scheduled on a thread pool for blocking operations
      Returns:
      a CompletableFuture that waits to complete till the supplier is ready to be executedx in the thread pool and produces the result of type T