Skip to content

Instantly share code, notes, and snippets.

@trustin
Created July 6, 2012 03:21
Show Gist options
  • Select an option

  • Save trustin/3057879 to your computer and use it in GitHub Desktop.

Select an option

Save trustin/3057879 to your computer and use it in GitHub Desktop.
private void sendNumbers() {
// Do not send more than 4096 numbers.
boolean finished = false;
MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
while (out.size() < 4096) {
if (i <= count) {
out.add(Integer.valueOf(i));
i ++;
} else {
finished = true;
break;
}
}
ChannelFuture f = ctx.flush();
if (!finished) {
f.addListener(SEND_NUMBERS);
}
}
private final ChannelFutureListener SEND_NUMBERS = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
sendNumbers();
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment