public static class F.Promise<A>
extends java.lang.Object
A.| Modifier and Type | Class and Description |
|---|---|
static class |
F.Promise.PromiseActor |
| Constructor and Description |
|---|
F.Promise(scala.concurrent.Future<A> promise)
Create a new promise wrapping the given Scala promise
|
| Modifier and Type | Method and Description |
|---|---|
<B> F.Promise<B> |
flatMap(F.Function<A,F.Promise<B>> function)
Maps the result of this promise to a promise for a result of type
B, and flattens that to be
a single promise for B. |
A |
get()
Awaits for the promise to get the result using the default timeout (5000 milliseconds).
|
A |
get(java.lang.Long timeout)
Awaits for the promise to get the result.
|
A |
get(java.lang.Long timeout,
java.util.concurrent.TimeUnit unit)
Awaits for the promise to get the result.
|
scala.concurrent.Future<A> |
getWrappedPromise()
Get the underlying Scala promise
|
<B> F.Promise<B> |
map(F.Function<A,B> function)
Maps this promise to a promise of type
B. |
void |
onRedeem(F.Callback<A> action)
Perform the given
action callback when the Promise is redeemed. |
<B> F.Promise<F.Either<A,B>> |
or(F.Promise<B> another)
combines the current promise with
another promise using `or` |
static <A> F.Promise<A> |
pure(A a)
Create a new pure promise, that is, a promise with a constant value from the start.
|
F.Promise<A> |
recover(F.Function<java.lang.Throwable,A> function)
Wraps this promise in a promise that will handle exceptions thrown by this Promise.
|
static void |
resetActors() |
static <A> F.Promise<java.util.List<A>> |
sequence(F.Promise<? extends A>... promises)
Combine the given promises into a single promise for the list of results.
|
static <A> F.Promise<java.util.List<A>> |
sequence(java.lang.Iterable<F.Promise<? extends A>> promises)
Combine the given promises into a single promise for the list of results.
|
static <A> F.Promise<A> |
throwing(java.lang.Throwable throwable)
Create a new promise throwing an exception.
|
static F.Promise<scala.Unit> |
timeout()
Create a Promise timer that is throwing a TimeoutException after the default timeout duration expires.
|
static <A> F.Promise<A> |
timeout(A message,
java.lang.Long delay)
Create a Promise that is redeemed after a timeout.
|
static <A> F.Promise<A> |
timeout(A message,
java.lang.Long delay,
java.util.concurrent.TimeUnit unit)
Create a Promise that is redeemed after a timeout.
|
static <A> F.Promise<java.util.List<A>> |
waitAll(F.Promise<? extends A>... promises)
Deprecated.
As of release 2.1, replaced by
sequence(play.libs.F.Promise<? extends A>...) |
static <A> F.Promise<java.util.List<A>> |
waitAll(java.lang.Iterable<F.Promise<? extends A>> promises)
Deprecated.
As of release 2.1, replaced by
sequence(play.libs.F.Promise<? extends A>...) |
public F.Promise(scala.concurrent.Future<A> promise)
promise - The scala promise to wrappublic static void resetActors()
public static <A> F.Promise<java.util.List<A>> sequence(F.Promise<? extends A>... promises)
promises - The promises to combine@Deprecated public static <A> F.Promise<java.util.List<A>> waitAll(F.Promise<? extends A>... promises)
sequence(play.libs.F.Promise<? extends A>...)promises - The promises to combinepublic static <A> F.Promise<A> timeout(A message, java.lang.Long delay, java.util.concurrent.TimeUnit unit)
message - The message to use to redeem the Promise.delay - The delay (expressed with the corresponding unit).unit - The Unit.public static F.Promise<scala.Unit> timeout() throws java.util.concurrent.TimeoutException
java.util.concurrent.TimeoutExceptionpublic static <A> F.Promise<A> timeout(A message, java.lang.Long delay)
message - The message to use to redeem the Promise.delay - The delay expressed in Milliseconds.public static <A> F.Promise<java.util.List<A>> sequence(java.lang.Iterable<F.Promise<? extends A>> promises)
promises - The promises to combine@Deprecated public static <A> F.Promise<java.util.List<A>> waitAll(java.lang.Iterable<F.Promise<? extends A>> promises)
sequence(play.libs.F.Promise<? extends A>...)promises - The promises to combinepublic static <A> F.Promise<A> pure(A a)
a - the value for the promisepublic static <A> F.Promise<A> throwing(java.lang.Throwable throwable)
throwable - Value to throwpublic A get()
java.lang.RuntimeException - if the calculation providing the promise threw an exceptionpublic A get(java.lang.Long timeout, java.util.concurrent.TimeUnit unit)
timeout - A user defined timeoutunit - timeout for timeoutjava.lang.RuntimeException - if the calculation providing the promise threw an exceptionpublic A get(java.lang.Long timeout)
timeout - A user defined timeout in millisecondsjava.lang.RuntimeException - if the calculation providing the promise threw an exceptionpublic <B> F.Promise<F.Either<A,B>> or(F.Promise<B> another)
another promise using `or`another - public void onRedeem(F.Callback<A> action)
action callback when the Promise is redeemed.action - The action to perform.public <B> F.Promise<B> map(F.Function<A,B> function)
B. The function function is applied as
soon as the promise is redeemed.
Exceptions thrown by function will be wrapped in RuntimeException, unless
they are RuntimeException's themselves.function - The function to map A to B.A to B.public F.Promise<A> recover(F.Function<java.lang.Throwable,A> function)
function will be wrapped in RuntimeException, unless
they are RuntimeException's themselves.function - The function to handle the exception. This may, for example, convert the exception into something
of type T, or it may throw another exception, or it may do some other handling.function throws an
exception.public <B> F.Promise<B> flatMap(F.Function<A,F.Promise<B>> function)
B, and flattens that to be
a single promise for B.
Exceptions thrown by function will be wrapped in RuntimeException, unless
they are RuntimeException's themselves.function - The function to map A to a promise for B.Bpublic scala.concurrent.Future<A> getWrappedPromise()