Move flushTaskInProgress to AbstractUnsafe

.. because it's referenced only there.  Also did tiny optimizations.
This commit is contained in:
Trustin Lee 2013-02-09 01:27:54 +09:00
parent a4c66dc282
commit e424a2f4b3
2 changed files with 8 additions and 12 deletions

View File

@ -98,8 +98,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
private boolean strValActive; private boolean strValActive;
private String strVal; private String strVal;
private AbstractUnsafe.FlushTask flushTaskInProgress;
/** /**
* Creates a new instance. * Creates a new instance.
* *
@ -489,6 +487,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
} }
}; };
private FlushTask flushTaskInProgress;
@Override @Override
public final void sendFile(final FileRegion region, final ChannelPromise promise) { public final void sendFile(final FileRegion region, final ChannelPromise promise) {
@ -515,7 +515,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
} }
private void sendFile0(FileRegion region, ChannelPromise promise) { private void sendFile0(FileRegion region, ChannelPromise promise) {
if (flushTaskInProgress == null) { FlushTask task = flushTaskInProgress;
if (task == null) {
flushTaskInProgress = new FlushTask(region, promise); flushTaskInProgress = new FlushTask(region, promise);
try { try {
// the first FileRegion to flush so trigger it now! // the first FileRegion to flush so trigger it now!
@ -527,7 +528,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
return; return;
} }
FlushTask task = flushTaskInProgress;
for (;;) { for (;;) {
FlushTask next = task.next; FlushTask next = task.next;
if (next == null) { if (next == null) {
@ -789,10 +789,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
@Override @Override
public void flush(final ChannelPromise promise) { public void flush(final ChannelPromise promise) {
if (eventLoop().inEventLoop()) { if (eventLoop().inEventLoop()) {
FlushTask task = flushTaskInProgress;
if (flushTaskInProgress != null) { if (task != null) {
FlushTask task = flushTaskInProgress;
// loop over the tasks to find the last one // loop over the tasks to find the last one
for (;;) { for (;;) {
FlushTask t = task.next; FlushTask t = task.next;

View File

@ -277,11 +277,9 @@ public abstract class AbstractNioChannel extends AbstractChannel {
} }
final int interestOps = selectionKey.interestOps(); final int interestOps = selectionKey.interestOps();
if ((interestOps & readInterestOp) != 0) { if ((interestOps & readInterestOp) == 0) {
return; selectionKey.interestOps(interestOps | readInterestOp);
} }
this.selectionKey.interestOps(interestOps | readInterestOp);
} }
/** /**