public abstract class IteratingNestedCallback extends IteratingCallback
This specialized callback is used when breaking up an asynchronous task into smaller asynchronous tasks. A typical pattern is that a successful callback is used to schedule the next sub task, but if that task completes quickly and uses the calling thread to callback the success notification, this can result in a growing stack depth.
To avoid this issue, this callback uses an AtomicBoolean to note if the success callback has been called during the processing of a sub task, and if so then the processing iterates rather than recurses.
This callback is passed to the asynchronous handling of each sub
task and a call the IteratingCallback.succeeded()
on this call back represents
completion of the subtask. Only once all the subtasks are completed is
the Callback.succeeded()
method called on the Callback
instance
passed the the IteratingNestedCallback(Callback)
constructor.
Callback.Adapter
Constructor and Description |
---|
IteratingNestedCallback(Callback callback) |
Modifier and Type | Method and Description |
---|---|
protected void |
completed() |
void |
failed(Throwable x)
Derivations of this method should always call super.failed(x)
to check the state before handling the failure.
|
String |
toString() |
iterate, process, succeeded
public IteratingNestedCallback(Callback callback)
protected void completed()
completed
in class IteratingCallback
public void failed(Throwable x)
IteratingCallback
failed
in interface Callback
failed
in class IteratingCallback
x
- the reason for the operation failureCallback.failed(java.lang.Throwable)
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.