A little bit of optimization that reduces interestOps() calls

This commit is contained in:
Trustin Lee 2013-02-11 10:39:50 +09:00
parent 488e56a9b1
commit a7b5d45bdf

View File

@ -141,8 +141,10 @@ public final class NioEventLoop extends SingleThreadEventLoop {
SelectionKey key = channel.selectionKey();
channel.writableTasks.offer(task);
if (!key.isWritable()) {
key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
int interestOps = key.interestOps();
if ((interestOps & SelectionKey.OP_WRITE) == 0) {
key.interestOps(interestOps | SelectionKey.OP_WRITE);
}
}