Revert as it should be in nio2 branch "Commit first round of classes to support nio2/async channel api. Still work in progress.. See #396"
This reverts commit 18aaae3c2e
.
This commit is contained in:
parent
41a9c66f66
commit
c165a38e15
4
pom.xml
4
pom.xml
@ -276,12 +276,14 @@
|
||||
<ignores>
|
||||
<ignore>sun.misc.Unsafe</ignore>
|
||||
<ignore>java.util.zip.Deflater</ignore>
|
||||
|
||||
<!-- Used for NIO UDP multicast -->
|
||||
<ignore>java.nio.channels.DatagramChannel</ignore>
|
||||
<ignore>java.nio.channels.MembershipKey</ignore>
|
||||
<ignore>java.net.StandardSocketOptions</ignore>
|
||||
<ignore>java.net.StandardProtocolFamily</ignore>
|
||||
<!-- Used for NIO2 -->
|
||||
|
||||
<!-- Used for NIO. 2 -->
|
||||
<ignore>java.nio.channels.AsynchronousChannel</ignore>
|
||||
<ignore>java.nio.channels.AsynchronousSocketChannel</ignore>
|
||||
<ignore>java.nio.channels.AsynchronousServerSocketChannel</ignore>
|
||||
|
@ -85,7 +85,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
private ClosedChannelException closedChannelException;
|
||||
private final Deque<FlushCheckpoint> flushCheckpoints = new ArrayDeque<FlushCheckpoint>();
|
||||
private long writeCounter;
|
||||
protected boolean inFlushNow;
|
||||
private boolean inFlushNow;
|
||||
private boolean flushNowPending;
|
||||
|
||||
/** Cache for the string representation of this channel */
|
||||
@ -623,7 +623,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushNow() {
|
||||
public final void flushNow() {
|
||||
if (inFlushNow) {
|
||||
return;
|
||||
}
|
||||
@ -631,13 +631,12 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
inFlushNow = true;
|
||||
ChannelHandlerContext ctx = directOutboundContext();
|
||||
Throwable cause = null;
|
||||
boolean handleFlush = true;
|
||||
try {
|
||||
if (ctx.hasOutboundByteBuffer()) {
|
||||
ByteBuf out = ctx.outboundByteBuffer();
|
||||
int oldSize = out.readableBytes();
|
||||
try {
|
||||
handleFlush = doFlushByteBuffer(out);
|
||||
doFlushByteBuffer(out);
|
||||
} catch (Throwable t) {
|
||||
cause = t;
|
||||
} finally {
|
||||
@ -658,15 +657,14 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
writeCounter += oldSize - out.size();
|
||||
}
|
||||
}
|
||||
if (handleFlush) {
|
||||
if (cause == null) {
|
||||
notifyFlushFutures();
|
||||
} else {
|
||||
notifyFlushFutures(cause);
|
||||
pipeline.fireExceptionCaught(cause);
|
||||
if (cause instanceof IOException) {
|
||||
close(voidFuture());
|
||||
}
|
||||
|
||||
if (cause == null) {
|
||||
notifyFlushFutures();
|
||||
} else {
|
||||
notifyFlushFutures(cause);
|
||||
pipeline.fireExceptionCaught(cause);
|
||||
if (cause instanceof IOException) {
|
||||
close(voidFuture());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@ -715,7 +713,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
|
||||
protected abstract void doClose() throws Exception;
|
||||
protected abstract void doDeregister() throws Exception;
|
||||
protected boolean doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
protected void doFlushMessageBuffer(MessageBuf<Object> buf) throws Exception {
|
||||
@ -724,7 +722,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
|
||||
protected abstract boolean isFlushPending();
|
||||
|
||||
protected final void notifyFlushFutures() {
|
||||
private void notifyFlushFutures() {
|
||||
if (flushCheckpoints.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -762,7 +760,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
}
|
||||
}
|
||||
|
||||
protected final void notifyFlushFutures(Throwable cause) {
|
||||
private void notifyFlushFutures(Throwable cause) {
|
||||
notifyFlushFutures();
|
||||
for (;;) {
|
||||
FlushCheckpoint cp = flushCheckpoints.poll();
|
||||
|
@ -77,7 +77,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -71,11 +71,10 @@ public class EmbeddedByteChannel extends AbstractEmbeddedChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
if (!lastOutboundBuffer().readable()) {
|
||||
lastOutboundBuffer().discardReadBytes();
|
||||
}
|
||||
lastOutboundBuffer().writeBytes(buf);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -85,11 +85,11 @@ abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
if (!buf.readable()) {
|
||||
// Reset reader/writerIndex to 0 if the buffer is empty.
|
||||
buf.clear();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = config().getWriteSpinCount() - 1; i >= 0; i --) {
|
||||
@ -103,7 +103,6 @@ abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract int doReadBytes(ByteBuf buf) throws Exception;
|
||||
|
@ -86,12 +86,11 @@ abstract class AbstractOioByteChannel extends AbstractOioChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||
while (buf.readable()) {
|
||||
doWriteBytes(buf);
|
||||
}
|
||||
buf.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract int available();
|
||||
|
Loading…
Reference in New Issue
Block a user