Skip to content

Commit 5ee1e14

Browse files
committed
Fixed SLOW_PASS_THRU to prevent JIT optimizing it away.
1 parent f410739 commit 5ee1e14

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/test/java/rx/BackpressureTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,14 +549,16 @@ public void call(final Subscriber<? super Integer> s) {
549549
}
550550

551551
final static Func1<Integer, Integer> SLOW_PASS_THRU = new Func1<Integer, Integer>() {
552-
552+
volatile int sink;
553553
@Override
554554
public Integer call(Integer t1) {
555555
// be slow ... but faster than Thread.sleep(1)
556556
String t = "";
557+
int s = sink;
557558
for (int i = 1000; i >= 0; i--) {
558-
t = String.valueOf(i + t.hashCode());
559+
t = String.valueOf(i + t.hashCode() + s);
559560
}
561+
sink = t.hashCode();
560562
return t1;
561563
}
562564

0 commit comments

Comments
 (0)