Class CountingCallback
java.lang.Object
org.eclipse.jetty.util.Callback.Completing
org.eclipse.jetty.util.Callback.Nested
org.eclipse.jetty.util.CountingCallback
A callback wrapper that succeeds the wrapped callback when the count is reached, or on first failure.
This callback is particularly useful when an async operation is split into multiple parts, for example when an original byte buffer that needs to be written, along with a callback, is split into multiple byte buffers, since it allows the original callback to be wrapped and notified only when the last part has been processed.
Example:
public void process(EndPoint endPoint, ByteBuffer buffer, Callback callback)
{
ByteBuffer[] buffers = split(buffer);
CountCallback countCallback = new CountCallback(callback, buffers.length);
endPoint.write(countCallback, buffers);
}
-
Nested Class Summary
Nested classes/interfaces inherited from interface Callback
Callback.Completable, Callback.Completing, Callback.InvocableCallback, Callback.NestedNested classes/interfaces inherited from interface Invocable
Invocable.InvocationType -
Field Summary
FieldsFields inherited from interface Invocable
__nonBlocking -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class Callback.Nested
getCallback, getInvocationTypeMethods inherited from class Callback.Completing
completed
-
Field Details
-
count
-
-
Constructor Details
-
CountingCallback
-
-
Method Details
-
succeeded
public void succeeded()Description copied from interface:CallbackCallback invoked when the operation completes.
- Specified by:
succeededin interfaceCallback- Overrides:
succeededin classCallback.Nested- See Also:
-
failed
-
toString
-