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

View File

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