Class Futures$

java.lang.Object
org.apache.pekko.dispatch.Futures$

public class Futures$ extends Object
Futures is the Java API for Futures and Promises
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Futures$
    Static reference to the singleton instance of this Scala object.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    asJava(scala.concurrent.Future<T> future)
    Convert a Scala Future to a Java CompletionStage.
    <T> scala.concurrent.Future<T>
    failed(Throwable exception)
    creates an already completed Promise with the specified exception
    Deprecated.
    Use `CompletableFuture#failedStage` instead.
    <T> scala.concurrent.Future<T>
    future(Callable<T> body, scala.concurrent.ExecutionContext executor)
    Starts an asynchronous computation and returns a Future object with the result of that computation.
    <T> scala.concurrent.Promise<T>
    Creates a promise object which can be completed with a value.
    <T> scala.concurrent.Future<T>
    successful(T result)
    Creates an already completed Promise with the specified result

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MODULE$

      public static final Futures$ MODULE$
      Static reference to the singleton instance of this Scala object.
  • Constructor Details

    • Futures$

      public Futures$()
  • Method Details

    • asJava

      public <T> CompletionStage<T> asJava(scala.concurrent.Future<T> future)
      Convert a Scala Future to a Java CompletionStage.

      Since:
      1.2.0
    • future

      public <T> scala.concurrent.Future<T> future(Callable<T> body, scala.concurrent.ExecutionContext executor)
      Starts an asynchronous computation and returns a Future object with the result of that computation.

      The result becomes available once the asynchronous computation is completed.

      Parameters:
      body - the asynchronous computation
      executor - the execution context on which the future is run
      Returns:
      the Future holding the result of the computation
    • promise

      public <T> scala.concurrent.Promise<T> promise()
      Creates a promise object which can be completed with a value.

      Returns:
      the newly created Promise object
    • failed

      public <T> scala.concurrent.Future<T> failed(Throwable exception)
      creates an already completed Promise with the specified exception
    • successful

      public <T> scala.concurrent.Future<T> successful(T result)
      Creates an already completed Promise with the specified result
    • failedCompletionStage

      public <T> CompletionStage<T> failedCompletionStage(Throwable ex)
      Deprecated.
      Use `CompletableFuture#failedStage` instead. Since 2.0.0.
      Creates an already completed CompletionStage with the specified exception