Created
July 6, 2012 03:21
-
-
Save trustin/3057879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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