Skip to content

Commit 02729e6

Browse files
committed
Use the channel read complete event to process pending messages.
Motivation: When the socket uses pipeling and there are pending messages (due to pipelining limit), the pending message queue will likely be examined for sending by each message read. Examining the pending message queue is more efficient when done upon channel read complete. Changes: Move the pending message check in the read completion event, rather that after each processed messsage.
1 parent c761afb commit 02729e6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SocketConnectionBase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public void init() {
134134
handleException(e);
135135
}
136136
});
137+
socket.readCompletionHandler(this::handleReadComplete);
137138
}
138139

139140
public NetSocketInternal socket() {
@@ -313,13 +314,16 @@ protected void handleMessage(Object msg) {
313314
inflight--;
314315
CommandResponse resp =(CommandResponse) msg;
315316
resp.fire();
316-
checkPending();
317317
} else if (msg instanceof InvalidCachedStatementEvent) {
318318
InvalidCachedStatementEvent event = (InvalidCachedStatementEvent) msg;
319319
removeCachedStatement(event.sql());
320320
}
321321
}
322322

323+
private void handleReadComplete(Void v) {
324+
checkPending();
325+
}
326+
323327
protected void handleEvent(Object event) {
324328
if (holder != null) {
325329
holder.handleEvent(event);

0 commit comments

Comments
 (0)