Skip to content

Commit 06322db

Browse files
committed
tidy up flow in tryAcquire
1 parent ef14c09 commit 06322db

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/AbstractPartitionedLimiter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ void acquire() {
146146
* @return
147147
*/
148148
boolean tryAcquire() {
149-
while (true) {
150-
int current = busy.get();
151-
if (current >= limit) {
152-
return false;
153-
}
149+
int current = busy.get();
150+
while (current < limit) {
154151
if (busy.compareAndSet(current, current + 1)) {
155152
inflightDistribution.addSample(current + 1);
156153
return true;
157154
}
155+
current = busy.get();
158156
}
157+
158+
return false;
159159
}
160160

161161
void release() {

0 commit comments

Comments
 (0)