Interface AsyncBiFunction<T,P,R>

Type Parameters:
T - the type of the first argument to the function
P - the type of the second argument to the function
R - 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.

@FunctionalInterface public interface AsyncBiFunction<T,P,R> extends Async<R>
The 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 Type
    Method
    Description
    void
    applyAsync(T t, P p)
    Asynchronously applies this function to the given arguments.
    async(T t, P p)
    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

      void applyAsync(T t, P p) throws IOException
      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 function
      p - the second argument to the function
      Throws:
      IOException - if an I/O error occurs during the application of the function
    • async

      default CompletableFuture<R> async(T t, P p) throws IOException
      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 function
      p - 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