Class IteratingNestedCallback
- java.lang.Object
-
- org.eclipse.jetty.util.IteratingCallback
-
- org.eclipse.jetty.util.IteratingNestedCallback
-
public abstract class IteratingNestedCallback extends IteratingCallback
Iterating Nested Callback.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 theCallback.succeeded()
method called on theCallback
instance passed the theIteratingNestedCallback(Callback)
constructor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.IteratingCallback
IteratingCallback.Action
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Callback
Callback.Completable, Callback.Completing, Callback.Nested
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.InvocationType
-
-
Field Summary
-
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking
-
-
Constructor Summary
Constructors Constructor Description IteratingNestedCallback(Callback callback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Invocable.InvocationType
getInvocationType()
protected void
onCompleteFailure(java.lang.Throwable x)
Invoked when the overall task has completed with a failure.protected void
onCompleteSuccess()
Invoked when the overall task has completed successfully.java.lang.String
toString()
-
Methods inherited from class org.eclipse.jetty.util.IteratingCallback
close, failed, isClosed, isFailed, isSucceeded, iterate, process, reset, succeeded
-
-
-
-
Constructor Detail
-
IteratingNestedCallback
public IteratingNestedCallback(Callback callback)
-
-
Method Detail
-
getInvocationType
public Invocable.InvocationType getInvocationType()
- Returns:
- The InvocationType of this object
-
onCompleteSuccess
protected void onCompleteSuccess()
Description copied from class:IteratingCallback
Invoked when the overall task has completed successfully.- Overrides:
onCompleteSuccess
in classIteratingCallback
- See Also:
IteratingCallback.onCompleteFailure(Throwable)
-
onCompleteFailure
protected void onCompleteFailure(java.lang.Throwable x)
Description copied from class:IteratingCallback
Invoked when the overall task has completed with a failure.- Overrides:
onCompleteFailure
in classIteratingCallback
- Parameters:
x
- the throwable to indicate cause of failure- See Also:
IteratingCallback.onCompleteSuccess()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classIteratingCallback
-
-