public interface Async
Support for asynchronous execution of synchronous (blocking) calls.
While this does not miraculously make a synchronous call non-blocking, it at least moves
the blocking calls to a separate executor service, degrading the service gracefully.
Example of usage:
// async instance with default executor service Async async = Async.create(); // call a method with no parameters Single<String> result = async.invoke(this::slowSync); // call a method with parameters async.invoke(() -> processRequest(request)) .thenApply(response::send); // use async to obtain a Multi (from a method returning List of strings) Multi<String> stringMulti = async.invoke(this::syncList) .flatMap(Multi::create);
-
Nested Class Summary
-
Method Summary
-
Method Details
-
invoke
Invoke a synchronous operation asynchronously. This method never throws an exception. Any exception is returned via theSingle
result.- Type Parameters:
T
- type of returned value- Parameters:
supplier
- supplier of value (may be 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
-
builder
A new builder to build a customizedAsync
instance.- Returns:
- a new builder
-