|
barchart-util-concurrent 2.0.16 / 2012-12-19T12:07:36.441-0600 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
E - The result typepublic interface FutureCallback<V,T extends FutureCallback<V,T>>
Adds listener notification methods to Future to allow immediate
notification when a result is available.
Example:
FutureListener<Employee> listener = new FutureListener<Employee> {
public void resultAvailable(Future<Employee> result) {
System.out.println("Got deferred result: " + result.get());
}
}
FutureCallback<Employee> result = myDataStore.getEmployee(id);
result.addResultListener(listener);
In this example, getEmployee() returns a FutureCallback object that it will later use to return a result asynchronously. When it has a result, it calls result.succeed(Employee e), which in turn notifies any listeners registered with result.addResultListener(). If the call fails, the owner may call result.fail(Exception ex) to report the error. If a FutureCallback has failed, any future calls to result.get() throw an ExecutionException with the original exception as its cause.
This class is thread-safe.
Future,
FutureListener,
FutureCallbackTask| Method Summary | |
|---|---|
T |
addResultListener(FutureListener<V> listener)
Register a listener for this deferred result. |
T |
fail(Throwable error)
Notify listeners that an error occurred. |
V |
getUnchecked()
Get the return value, or null if a checked exception was caught. |
T |
succeed(V result)
Notify listeners that a result is available. |
| Methods inherited from interface java.util.concurrent.Future |
|---|
cancel, get, get, isCancelled, isDone |
| Method Detail |
|---|
T addResultListener(FutureListener<V> listener)
listener - The listener objectT succeed(V result)
return new FutureCallbackTask
result_ - The deferred result
T fail(Throwable error)
return new FutureCallbackTask
error_ - The deferred errorV getUnchecked()
|
barchart-util-concurrent 2.0.16 / 2012-12-19T12:07:36.441-0600 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||