Add a boolean parameter to Channel.Unsafe.flush() so that SelectionKey state check can be bypassed.
This commit is contained in:
parent
e10e9d38c4
commit
99716993f6
@ -592,12 +592,12 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
public void flush(boolean force) {
|
||||
outboundBuffer.addFlush();
|
||||
flush0();
|
||||
flush0(force);
|
||||
}
|
||||
|
||||
private void flush0() {
|
||||
private void flush0(boolean force) {
|
||||
if (inFlushNow) {
|
||||
// Avoid re-entrance
|
||||
return;
|
||||
@ -606,7 +606,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
// Flush immediately only when there's no pending flush.
|
||||
// If there's a pending flush operation, event loop will call flushNow() later,
|
||||
// and thus there's no need to call it now.
|
||||
if (isFlushPending()) {
|
||||
if (!force || isFlushPending()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
public void flush(boolean force) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ public interface Channel extends AttributeMap, ChannelOutboundInvoker, ChannelPr
|
||||
/**
|
||||
* Flush out all write operations scheduled via {@link #write(Object, ChannelPromise)}.
|
||||
*/
|
||||
void flush();
|
||||
void flush(boolean force);
|
||||
|
||||
/**
|
||||
* Return a special ChannelPromise which can be reused and passed to the operations in {@link Unsafe}.
|
||||
|
@ -1030,7 +1030,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx) throws Exception {
|
||||
unsafe.flush();
|
||||
unsafe.flush(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -529,7 +529,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
||||
}
|
||||
|
||||
// Call flushNow which will also take care of clear the OP_WRITE once there is nothing left to write
|
||||
ch.unsafe().flush();
|
||||
ch.unsafe().flush(true);
|
||||
}
|
||||
|
||||
private static void unregisterWritableTasks(AbstractNioChannel ch) {
|
||||
|
Loading…
Reference in New Issue
Block a user