Interface AsyncBiFunction<T,P,R>
- Type Parameters:
T- the type of the first argument to the functionP- the type of the second argument to the functionR- the type of the result of the function
- All Superinterfaces:
Async<R>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
AsyncBiFunction interface represents a bi-function that
asynchronously accepts two arguments and produces a result. This interface
extends the Async interface and provides a method to apply the
function asynchronously.
Implementations of this interface are expected to perform an
asynchronous operation that takes two parameters of types T and P, and
returns a result of type R. The asynchronous operation is typically
represented as a CompletableFuture of the result type R.
For example, an implementation of this interface might perform an asynchronous computation using the two input parameters and return a future representing the result of that computation.
- See Also:
-
Field Summary
Fields inherited from interface org.apache.hadoop.hdfs.server.federation.router.async.utils.Async
CUR_COMPLETABLE_FUTURE -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyAsync(T t, P p) Asynchronously applies this function to the given arguments.default CompletableFuture<R>Initiates the asynchronous application of this function to the given result.Methods inherited from interface org.apache.hadoop.hdfs.server.federation.router.async.utils.Async
getCurCompletableFuture, result, setCurCompletableFuture
-
Method Details
-
applyAsync
Asynchronously applies this function to the given arguments.This method is intended to initiate the function application without waiting for the result. It should be used when the operation can be performed in the background, and the result is not required immediately.
- Parameters:
t- the first argument to the functionp- the second argument to the function- Throws:
IOException- if an I/O error occurs during the application of the function
-
async
Initiates the asynchronous application of this function to the given result.This method calls applyAsync to start the asynchronous operation and then retrieves the current thread's CompletableFuture using getCurCompletableFuture. It returns this CompletableFuture, which will be completed with the result of the asynchronous operation once it is finished.
This method is useful for chaining with other asynchronous operations, as it allows the current operation to be part of a larger asynchronous workflow.
- Parameters:
t- the first argument to the functionp- the second argument to the function- Returns:
- a CompletableFuture that will be completed with the result of the asynchronous operation
- Throws:
IOException- if an I/O error occurs during the initiation of the asynchronous operation
-