Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,12 @@ public ClusterResponse sendRequest(ClusterRequest request) throws Exception {
}

private int getCurrentId() {
if (idGenerator.get() > MAX_ID) {
idGenerator.set(0);
}
return idGenerator.incrementAndGet();
int pre, next;
do {
pre = idGenerator.get();
next = pre >= MAX_ID ? MIN_ID : pre + 1;
} while (!idGenerator.compareAndSet(pre, next));
return next;
}

/*public CompletableFuture<ClusterResponse> sendRequestAsync(ClusterRequest request) {
Expand All @@ -266,5 +268,6 @@ private int getCurrentId() {
return future;
}*/

private static final int MIN_ID = 1;
private static final int MAX_ID = 999_999_999;
}