Class IteratingNestedCallback
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.
-
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.Combination, Callback.Completable, Callback.Completing, Callback.Nested
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.Callback
NOOP, NOT_CALLED
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Invoked when the overall task has completed successfully, specifically after anyIteratingCallback.Action.SCHEDULED
operations haveCallback.succeeded()
andIteratingCallback.process()
has returnedIteratingCallback.Action.SUCCEEDED
.protected void
toString()
Methods inherited from class org.eclipse.jetty.util.IteratingCallback
abort, close, failed, isAborted, isClosed, isFailed, isSucceeded, iterate, onAborted, onCompleted, onCompleteFailure, onSuccess, process, reset, succeeded
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.Callback
completeWith
-
Constructor Details
-
IteratingNestedCallback
-
-
Method Details
-
getInvocationType
- Returns:
- The InvocationType of this object
-
onCompleteSuccess
protected void onCompleteSuccess()Description copied from class:IteratingCallback
Invoked when the overall task has completed successfully, specifically after anyIteratingCallback.Action.SCHEDULED
operations haveCallback.succeeded()
andIteratingCallback.process()
has returnedIteratingCallback.Action.SUCCEEDED
.Calls to this method are serialized with respect to
IteratingCallback.process()
,IteratingCallback.onAborted(Throwable)
andIteratingCallback.onCompleted(Throwable)
. If this method is called, thenIteratingCallback.onCompleteFailure(Throwable)
()} will never be called.- Overrides:
onCompleteSuccess
in classIteratingCallback
- See Also:
-
onFailure
Description copied from class:IteratingCallback
Invoked when the overall task has beenaborted
orfailed
.Calls to this method are serialized with respect to
IteratingCallback.onAborted(Throwable)
,IteratingCallback.process()
,IteratingCallback.onCompleteFailure(Throwable)
andIteratingCallback.onCompleted(Throwable)
.Because
onFailure
can be called due to anIteratingCallback.abort(Throwable)
orIteratingCallback.close()
operation, it is possible that any resources passed to aIteratingCallback.Action.SCHEDULED
operation may still be in use, and thus should not be recycled by this call. For example any buffers passed to a write operation should not be returned to a buffer pool by implementations ofonFailure
. Such resources may be discarded here, or safely recycled in a subsequent call toIteratingCallback.onCompleted(Throwable)
orIteratingCallback.onCompleteFailure(Throwable)
, when theIteratingCallback.Action.SCHEDULED
operation has completed.- Overrides:
onFailure
in classIteratingCallback
- Parameters:
x
- The cause of the failure or abort- See Also:
-
toString
- Overrides:
toString
in classIteratingCallback
-