Class AsyncHelper$


  • public class AsyncHelper$
    extends java.lang.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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static AsyncHelper$ MODULE$
      Static reference to the singleton instance of this Scala object.
    • Constructor Summary

      Constructors 
      Constructor Description
      AsyncHelper$()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> java.util.concurrent.CompletableFuture<T> managedBlock​(java.util.function.Supplier<T> supplier)
      The method wraps ForkJoinPool#managedBlock() and executes the provided supplier in a dedicated thread pool for blocking operations
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODULE$

        public static final AsyncHelper$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • AsyncHelper$

        public AsyncHelper$()
    • Method Detail

      • managedBlock

        public <T> java.util.concurrent.CompletableFuture<T> managedBlock​(java.util.function.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