Optimize AbstractNioWorker.cleanUpWriteBuffer(..). See #293

This commit is contained in:
Norman Maurer 2012-04-30 20:26:44 +02:00
parent 94b10d2d02
commit 2a70df1c1c

View File

@ -919,7 +919,11 @@ abstract class AbstractNioWorker implements Worker {
}
Queue<MessageEvent> writeBuffer = channel.writeBufferQueue;
if (!writeBuffer.isEmpty()) {
for (;;) {
evt = writeBuffer.poll();
if (evt == null) {
break;
}
// Create the exception only once to avoid the excessive overhead
// caused by fillStackTrace.
if (cause == null) {
@ -928,16 +932,10 @@ abstract class AbstractNioWorker implements Worker {
} else {
cause = new ClosedChannelException();
}
}
for (;;) {
evt = writeBuffer.poll();
if (evt == null) {
break;
}
evt.getFuture().setFailure(cause);
fireExceptionCaught = true;
}
}
}