FutureConverters
This object contains methods that convert between Scala scala.concurrent.Future and Java java.util.concurrent.CompletionStage.
This object contains methods that convert between Scala scala.concurrent.Future and Java java.util.concurrent.CompletionStage.
The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.FutureConverters.
Note that the bridge is implemented at the read-only side of asynchronous handles, namely
scala.concurrent.Future (instead of scala.concurrent.Promise) and java.util.concurrent.CompletionStage (instead of
java.util.concurrent.CompletableFuture). This is intentional, as the semantics of bridging
the write-handles would be prone to race conditions; if both ends (CompletableFuture
and
Promise
) are completed independently at the same time, they may contain different values
afterwards. For this reason, toCompletableFuture
is not supported on the created
CompletionStage
s.
Value members
Concrete methods
Returns a java.util.concurrent.CompletionStage that will be completed with the same value or exception as the given Scala scala.concurrent.Future when that completes.
Returns a java.util.concurrent.CompletionStage that will be completed with the same value or exception as the
given Scala scala.concurrent.Future when that completes. Since the Future is a read-only representation,
this CompletionStage does not support the toCompletableFuture
method.
The semantics of Scala Future demand that all callbacks are invoked asynchronously by default,
therefore the returned CompletionStage routes all calls to synchronous transformations to
their asynchronous counterparts, i.e., thenRun
will internally call thenRunAsync
.
- Value Params
- f
The Scala Future which may eventually supply the completion for the returned CompletionStage
- Returns
a CompletionStage that runs all callbacks asynchronously and does not support the CompletableFuture interface
Returns a Scala scala.concurrent.Future that will be completed with the same value or exception as the given java.util.concurrent.CompletionStage when that completes.
Returns a Scala scala.concurrent.Future that will be completed with the same value or exception as the given java.util.concurrent.CompletionStage when that completes. Transformations of the returned Future are executed asynchronously as specified by the ExecutionContext that is given to the combinator methods.
- Value Params
- cs
The CompletionStage which may eventually supply the completion for the returned Scala Future
- Returns
a Scala Future that represents the CompletionStage's completion