public final class Promise extends java.lang.Object
gololang.Async
module.Future
,
AssignedFuture
Constructor and Description |
---|
Promise() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
blockingGet()
Blocking get, waiting until the promise is resolved.
|
Promise |
fail(java.lang.Throwable throwable)
Fails the promise.
|
Future |
future()
Creates a new future to observe the eventual resolution of this promise.
|
java.lang.Object |
get()
Non-blocking get.
|
boolean |
isFailed()
Checks whether the promise has failed.
|
boolean |
isResolved()
Checks whether the promise has been resolved.
|
Promise |
set(java.lang.Object value)
Sets the promise value.
|
java.lang.String |
toString() |
public Promise()
public boolean isResolved()
true
if it has been resolved, false
otherwise.public boolean isFailed()
true
if it has been resolved and failed, false
otherwise.public java.lang.Object get()
null
if it has not been resolved yet.public java.lang.Object blockingGet() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the current thread gets interrupted.public Promise set(java.lang.Object value)
value
- the value.public Promise fail(java.lang.Throwable throwable)
throwable
- the failure.public Future future()
public java.lang.String toString()
toString
in class java.lang.Object