Package csw.database.javadsl
Class AsyncHelper
- java.lang.Object
-
- csw.database.javadsl.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.
-
-
Constructor Summary
Constructors Constructor Description AsyncHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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
-
-
-
Method Detail
-
managedBlock
public static <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
-
-