From d3267502229b574adfe75c15bbfef26226339f30 Mon Sep 17 00:00:00 2001 From: redkale Date: Wed, 30 Aug 2023 00:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96fastWrite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/redkale/net/AsyncNioConnection.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/redkale/net/AsyncNioConnection.java b/src/main/java/org/redkale/net/AsyncNioConnection.java index 7bf7bdb25..c1da68dc5 100644 --- a/src/main/java/org/redkale/net/AsyncNioConnection.java +++ b/src/main/java/org/redkale/net/AsyncNioConnection.java @@ -384,7 +384,7 @@ abstract class AsyncNioConnection extends AsyncConnection { int totalCount = 0; boolean hasRemain = true; boolean writeCompleted = true; - + boolean fastMode = false; if (writeByteBuffer == null && writeByteBuffers == null && writeByteTuple1Array == null && fastWriteCount.get() > 0) { final ByteBuffer buffer = pollWriteBuffer(); ByteBufferWriter writer = null; @@ -400,6 +400,7 @@ abstract class AsyncNioConnection extends AsyncConnection { writer.put(item); } } + fastMode = true; this.writeBuffersOffset = 0; if (writer == null) { this.writeByteBuffer = buffer.flip(); @@ -500,6 +501,9 @@ abstract class AsyncNioConnection extends AsyncConnection { if (writeCompleted && (totalCount != 0 || !hasRemain)) { handleWrite(this.writeTotal + totalCount, null); + if (fastMode && fastWriteCount.get() > 0) { + doWrite(); + } } else if (writeKey == null) { ioWriteThread.register(selector -> { try {