Skip to content

Commit 669934e

Browse files
committed
use CAS loop
1 parent dcda8a8 commit 669934e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/java/rx/internal/operators/OnSubscribeRedo.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,15 @@ public void onError(Throwable e) {
236236
public void onNext(T v) {
237237
if (!done) {
238238
child.onNext(v);
239-
long cap = consumerCapacity.get();
240-
if (cap != Long.MAX_VALUE) {
241-
consumerCapacity.compareAndSet(cap, cap -1);
239+
while (true) {
240+
long cc = consumerCapacity.get();
241+
if (cc != Long.MAX_VALUE) {
242+
if (consumerCapacity.compareAndSet(cc, cc -1)) {
243+
break;
244+
}
245+
} else {
246+
break;
247+
}
242248
}
243249
}
244250
}

0 commit comments

Comments
 (0)