public interface Async
Runs synchronous suppliers asynchronously using virtual threads. Includes
convenient static method to avoid creating instances of this class.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Async.Builderbuilder()A new builder to build a customizedAsyncinstance.static Asynccreate()Async with default executor service.<T> CompletableFuture<T>Invoke a synchronous operation asynchronously.static <T> CompletableFuture<T>invokeStatic(Supplier<T> supplier) Convenience method to avoid having to callcreate().static <T> CompletableFuture<T>invokeStatic(Supplier<T> supplier, CompletableFuture<Async> onStart) Convenience method to avoid having to callcreate().
-
Method Details
-
invoke
Invoke a synchronous operation asynchronously. This method never throws an exception. Any exception is returned via theCompletableFutureresult.- 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
-
create
Async with default executor service.- Returns:
- a default async instance
-
invokeStatic
Convenience method to avoid having to callcreate().- 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 callcreate(). Also accepts anonStartfuture 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
-
builder
A new builder to build a customizedAsyncinstance.- Returns:
- a new builder
-