优化命名

This commit is contained in:
Redkale
2023-01-06 13:31:57 +08:00
parent 4e5a03bb65
commit 7ce7c71163
6 changed files with 16 additions and 18 deletions

View File

@@ -13,8 +13,6 @@ import java.util.*;
import java.util.concurrent.atomic.*;
import java.util.function.*;
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
import static javax.net.ssl.SSLEngineResult.HandshakeStatus.*;
import static javax.net.ssl.SSLEngineResult.Status.*;
import javax.net.ssl.*;
import static javax.net.ssl.SSLEngineResult.HandshakeStatus.*;
import static javax.net.ssl.SSLEngineResult.Status.*;
@@ -42,7 +40,7 @@ public abstract class AsyncConnection implements ChannelContext, Channel, AutoCl
private Object subobject; //用于存储绑定在Connection上的对象 同attributes 只绑定单个对象时尽量使用subobject而非attributes
protected final AsyncGroup ioGroup;
protected final AsyncIOGroup ioGroup;
protected final boolean client;
@@ -82,7 +80,7 @@ public abstract class AsyncConnection implements ChannelContext, Channel, AutoCl
//用于服务端的Socket, 等同于一直存在的readCompletionHandler
ProtocolCodec protocolCodec;
protected AsyncConnection(boolean client, AsyncGroup ioGroup, AsyncIOThread ioReadThread, AsyncIOThread ioWriteThread,
protected AsyncConnection(boolean client, AsyncIOGroup ioGroup, AsyncIOThread ioReadThread, AsyncIOThread ioWriteThread,
final int bufferCapacity, SSLBuilder sslBuilder, SSLContext sslContext, final LongAdder livingCounter, final LongAdder closedCounter) {
Objects.requireNonNull(ioGroup);
Objects.requireNonNull(ioReadThread);

View File

@@ -288,7 +288,7 @@ abstract class AsyncNioConnection extends AsyncConnection {
}
});
} else {
((AsyncIOGroup) ioGroup).interestOpsOr(ioReadThread, readKey, SelectionKey.OP_READ);
ioGroup.interestOpsOr(ioReadThread, readKey, SelectionKey.OP_READ);
}
} catch (Exception e) {
handleRead(0, e);
@@ -301,7 +301,7 @@ abstract class AsyncNioConnection extends AsyncConnection {
final boolean invokeDirect = direct;
int totalCount = 0;
boolean hasRemain = true;
boolean writeOver = true;
boolean writeCompleted = true;
if (invokeDirect) {
currWriteInvoker++;
}
@@ -373,7 +373,7 @@ abstract class AsyncNioConnection extends AsyncConnection {
}
if (writeCount == 0) {
if (hasRemain) {
writeOver = false;
writeCompleted = false;
writeTotal = totalCount;
}
break;
@@ -390,7 +390,7 @@ abstract class AsyncNioConnection extends AsyncConnection {
}
}
if (writeOver && (totalCount != 0 || !hasRemain)) {
if (writeCompleted && (totalCount != 0 || !hasRemain)) {
handleWrite(writeTotal + totalCount, null);
} else if (writeKey == null) {
ioWriteThread.register(selector -> {
@@ -402,7 +402,7 @@ abstract class AsyncNioConnection extends AsyncConnection {
}
});
} else {
((AsyncIOGroup) ioGroup).interestOpsOr(ioWriteThread, writeKey, SelectionKey.OP_WRITE);
ioGroup.interestOpsOr(ioWriteThread, writeKey, SelectionKey.OP_WRITE);
}
} catch (IOException e) {
handleWrite(0, e);
@@ -483,7 +483,7 @@ abstract class AsyncNioConnection extends AsyncConnection {
}
}
@Deprecated(since = "2.5.0")
@Deprecated(since = "2.5.0")
protected abstract ReadableByteChannel readableByteChannel();
@Deprecated(since = "2.5.0")

View File

@@ -37,7 +37,7 @@ public abstract class Request<C extends Context> {
protected int pipelineCount;
protected boolean pipelineOver;
protected boolean pipelineCompleted;
protected int hashid;
@@ -67,7 +67,7 @@ public abstract class Request<C extends Context> {
this.keepAlive = request.keepAlive;
this.pipelineIndex = request.pipelineIndex;
this.pipelineCount = request.pipelineCount;
this.pipelineOver = request.pipelineOver;
this.pipelineCompleted = request.pipelineCompleted;
this.hashid = request.hashid;
this.traceid = request.traceid;
this.channel = request.channel;
@@ -101,7 +101,7 @@ public abstract class Request<C extends Context> {
createTime = 0;
pipelineIndex = 0;
pipelineCount = 0;
pipelineOver = false;
pipelineCompleted = false;
keepAlive = false;
attributes.clear();
channel = null; // close it by response

View File

@@ -137,7 +137,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
this.output = null;
this.filter = null;
this.servlet = null;
boolean notpipeline = request.pipelineIndex == 0 || request.pipelineOver;
boolean notpipeline = request.pipelineIndex == 0 || request.pipelineCompleted;
request.recycle();
if (channel != null) {
if (notpipeline) {
@@ -224,7 +224,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
}
this.recycleListener = null;
}
if (request.keepAlive && (request.pipelineIndex == 0 || request.pipelineOver)) {
if (request.keepAlive && (request.pipelineIndex == 0 || request.pipelineCompleted)) {
AsyncConnection conn = removeChannel();
if (conn != null && conn.protocolCodec != null) {
this.responseConsumer.accept(this);

View File

@@ -258,8 +258,8 @@ public class HttpRequest extends Request<HttpContext> {
return maybews && "Upgrade".equalsIgnoreCase(getHeader("Connection")) && "GET".equalsIgnoreCase(method);
}
protected void setPipelineOver(boolean pipelineOver) {
this.pipelineOver = pipelineOver;
protected void setPipelineCompleted(boolean pipelineCompleted) {
this.pipelineCompleted = pipelineCompleted;
}
protected void setKeepAlive(boolean keepAlive) {

View File

@@ -963,7 +963,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
if (pipelineIndex > 0) {
boolean over = this.channel.writePipelineData(pipelineIndex, request.getPipelineCount(), data);
if (over) {
request.setPipelineOver(true);
request.setPipelineCompleted(true);
this.channel.flushPipelineData(this.pipelineWriteHandler);
} else {
removeChannel();