Move inFlush0 and outboundBuffer in AbstractChannel to AbstractUnsafe
.. because they are accessed by AbstractUnsafe much more often.
This commit is contained in:
parent
5e5df6bd09
commit
8828d5327a
@ -61,9 +61,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
private volatile EventLoop eventLoop;
|
private volatile EventLoop eventLoop;
|
||||||
private volatile boolean registered;
|
private volatile boolean registered;
|
||||||
|
|
||||||
private ChannelOutboundBuffer outboundBuffer = ChannelOutboundBuffer.newInstance(this);
|
|
||||||
private boolean inFlush0;
|
|
||||||
|
|
||||||
/** Cache for the string representation of this channel */
|
/** Cache for the string representation of this channel */
|
||||||
private boolean strValActive;
|
private boolean strValActive;
|
||||||
private String strVal;
|
private String strVal;
|
||||||
@ -82,7 +79,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWritable() {
|
public boolean isWritable() {
|
||||||
return outboundBuffer.getWritable();
|
ChannelOutboundBuffer buf = unsafe.outboundBuffer();
|
||||||
|
return buf != null && buf.getWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -366,6 +364,14 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
*/
|
*/
|
||||||
protected abstract class AbstractUnsafe implements Unsafe {
|
protected abstract class AbstractUnsafe implements Unsafe {
|
||||||
|
|
||||||
|
private ChannelOutboundBuffer outboundBuffer = ChannelOutboundBuffer.newInstance(AbstractChannel.this);
|
||||||
|
private boolean inFlush0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ChannelOutboundBuffer outboundBuffer() {
|
||||||
|
return outboundBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final SocketAddress localAddress() {
|
public final SocketAddress localAddress() {
|
||||||
return localAddress0();
|
return localAddress0();
|
||||||
@ -517,11 +523,11 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fail all queued messages
|
// fail all queued messages
|
||||||
ChannelOutboundBuffer outboundBuffer = AbstractChannel.this.outboundBuffer;
|
ChannelOutboundBuffer outboundBuffer = this.outboundBuffer;
|
||||||
outboundBuffer.failFlushed(CLOSED_CHANNEL_EXCEPTION);
|
outboundBuffer.failFlushed(CLOSED_CHANNEL_EXCEPTION);
|
||||||
outboundBuffer.failUnflushed(CLOSED_CHANNEL_EXCEPTION);
|
outboundBuffer.failUnflushed(CLOSED_CHANNEL_EXCEPTION);
|
||||||
outboundBuffer.recycle();
|
outboundBuffer.recycle();
|
||||||
AbstractChannel.this.outboundBuffer = null;
|
this.outboundBuffer = null;
|
||||||
|
|
||||||
if (wasActive && !isActive()) {
|
if (wasActive && !isActive()) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
@ -618,7 +624,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
ChannelOutboundBuffer outboundBuffer = AbstractChannel.this.outboundBuffer;
|
ChannelOutboundBuffer outboundBuffer = this.outboundBuffer;
|
||||||
if (outboundBuffer == null) {
|
if (outboundBuffer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -633,7 +639,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ChannelOutboundBuffer outboundBuffer = AbstractChannel.this.outboundBuffer;
|
final ChannelOutboundBuffer outboundBuffer = this.outboundBuffer;
|
||||||
if (outboundBuffer == null || outboundBuffer.isEmpty()) {
|
if (outboundBuffer == null || outboundBuffer.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -250,5 +250,10 @@ public interface Channel extends AttributeMap, ChannelOutboundInvoker, ChannelPr
|
|||||||
* that take a {@link ChannelPromise} as argument but for which you not want to get notified.
|
* that take a {@link ChannelPromise} as argument but for which you not want to get notified.
|
||||||
*/
|
*/
|
||||||
ChannelPromise voidPromise();
|
ChannelPromise voidPromise();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link ChannelOutboundBuffer} of the {@link Channel} where the pending write requests are stored.
|
||||||
|
*/
|
||||||
|
ChannelOutboundBuffer outboundBuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user