|
ref_send API 2.17 defensive programming in Java |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- referent typepublic interface Promise<T>
A promise for a referent.
If you conceptualize a reference as being like an arrow, where an invocation is started at the tail end of the arrow and delivered to the object pointed to by the head end of the arrow, then a promise is like the tail end of an arrow which doesn't yet point to anything. The object referred to by a promise can be determined later. Using a promise, an algorithm can refer to an object which will be the result of future computation.
reference | referrer ----> referent | promise end of the reference
There are three states for a promise: fulfilled,
rejected and unresolved. A fulfilled
promise is successfully bound to a referent, which can be either local or
remote. A rejected promise failed to acquire a referent, and
carries an Exception
specifying the reason for the failure. An
unresolved promise is in neither the success nor failure state. A
promise is resolved if it is in either the success or failure
state.
Method Summary | |
---|---|
T |
call()
Gets the current referent. |
Method Detail |
---|
T call() throws java.lang.Exception
For example:
final Promise<Foo> foo = … try { foo.call().bar(); } catch (final Exception reason) { // Either there is no referent, or the bar() invocation failed. throw reason; }
java.lang.Exception
- reason the referent is not known
|
ref_send API 2.17 defensive programming in Java |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1998-2009 Waterken Inc. under the terms of the MIT X license.