public class CountingCallback extends Callback.Nested
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);
}
Callback.Completable, Callback.Nested, Callback.NonBlocking| 构造器和说明 |
|---|
CountingCallback(Callback callback,
int count) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
failed(Throwable failure)
Callback invoked when the operation fails.
|
void |
succeeded()
Callback invoked when the operation completes.
|
String |
toString() |
isNonBlockingpublic CountingCallback(Callback callback, int count)
public void succeeded()
CallbackCallback invoked when the operation completes.
succeeded 在接口中 Callbacksucceeded 在类中 Callback.NestedCallback.failed(Throwable)public void failed(Throwable failure)
CallbackCallback invoked when the operation fails.
failed 在接口中 Callbackfailed 在类中 Callback.Nestedfailure - the reason for the operation failureCopyright © 2016. All rights reserved.