Client浼樺寲connIndex
This commit is contained in:
@@ -48,6 +48,8 @@ public abstract class Client<C extends ClientConnection<R, P>, R extends ClientR
|
|||||||
|
|
||||||
protected final LongAdder respDoneCounter = new LongAdder();
|
protected final LongAdder respDoneCounter = new LongAdder();
|
||||||
|
|
||||||
|
protected final AtomicLong connIndexSeq = new AtomicLong();
|
||||||
|
|
||||||
private final AtomicInteger connSeqno = new AtomicInteger();
|
private final AtomicInteger connSeqno = new AtomicInteger();
|
||||||
|
|
||||||
private boolean closed;
|
private boolean closed;
|
||||||
@@ -250,14 +252,14 @@ public abstract class Client<C extends ClientConnection<R, P>, R extends ClientR
|
|||||||
return CompletableFuture.completedFuture(cc);
|
return CompletableFuture.completedFuture(cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int connIndex;
|
|
||||||
final int size = this.connArray.length;
|
final int size = this.connArray.length;
|
||||||
WorkThread workThread = WorkThread.currWorkThread();
|
int connIndex = (int) Math.abs(connIndexSeq.getAndIncrement()) % size;
|
||||||
if (workThread != null && workThread.threads() == size) {
|
// WorkThread workThread = WorkThread.currWorkThread();
|
||||||
connIndex = workThread.index();
|
// if (workThread != null && workThread.threads() == size) {
|
||||||
} else {
|
// connIndex = workThread.index();
|
||||||
connIndex = (int) Math.abs(Thread.currentThread().getId() % size);
|
// } else {
|
||||||
}
|
// connIndex = (int) Math.abs(Thread.currentThread().getId() % size);
|
||||||
|
// }
|
||||||
// if (connIndex >= 0) {
|
// if (connIndex >= 0) {
|
||||||
C cc = (C) this.connArray[connIndex];
|
C cc = (C) this.connArray[connIndex];
|
||||||
if (cc != null && cc.isOpen()) {
|
if (cc != null && cc.isOpen()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user