|
Did this page help you?Yes No Tell us about it... |
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objectcom.amazonaws.services.simpleworkflow.flow.core.Promise<V>
V - The result type returned by this Promise's get method. Use
Void to represent Promise that indicates completion of
operation that doesn't return a value.public abstract class Promise<V>
Promise is a future like object that is used as a placeholder for a result of
an asynchronous API. Java Future is a synchronization construct that is used
to block a thread that called get() method if result is not available yet.
Promise differs from it as it cannot be used for blocking. A call to its
get() method throws IllegalStateException if result is not available yet. The
correct way to ensure that Promise is ready is to access it from a method
that is annotated as @Asynchronous and have the given Promise as one its
arguments or from Task.doExecute() method assuming that promise was
passed to the Task as a constructor parameter.
Promise is not linked to error handling like Future is. In case of exceptions
they are propagated to the TryCatchFinally.doCatch(Throwable) method
of the TryCatchFinally that owns the asynchronous task that failed.
See TryCatchFinally for more info on the error handling.
For promises that don't need a value and just used to ensure correct ordering
of asynchronous operations the common pattern to use Void as a
generic type.
| Constructor Summary | |
|---|---|
Promise()
|
|
| Method Summary | ||
|---|---|---|
static
|
asPromise(T value)
Convenience method for creating a Promise object which is in ready state and returns the passed in value when get() is called. |
|
abstract V |
get()
|
|
String |
getDescription()
|
|
abstract boolean |
isReady()
|
|
static Promise<Void> |
Void()
This is a factory method to create a Promise |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Promise()
| Method Detail |
|---|
public abstract V get()
IllegalStateException - if result of your asynchronous computation is not available
yetpublic abstract boolean isReady()
true if the result of your asynchronous computation
is availablepublic String getDescription()
AsyncScope.getAsynchronousThreadDumpAsString()public static <T> Promise<T> asPromise(T value)
The same as new
Settable
T - Type of valuevalue - Object to return when get() is called
public static Promise<Void> Void()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||