ref_send API 2.17
defensive programming in Java

org.ref_send.promise
Interface Promise<T>

Type Parameters:
T - referent type

public 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

call

T call()
       throws java.lang.Exception
Gets the current referent.

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;
 }
 

Throws:
java.lang.Exception - reason the referent is not known

ref_send API 2.17
defensive programming in Java

Submit a bug or feature, or get help

Copyright 1998-2009 Waterken Inc. under the terms of the MIT X license.