@Test public void invalidDeferredRequest() { SubscriptionArbiter sa = new SubscriptionArbiter(); List<Throwable> errors = TestHelper.trackPluginErrors(); try { sa.request(-99); TestHelper.assertError(errors, 0, IllegalArgumentException.class, "n > 0 required but it was -99"); } finally { RxJavaPlugins.reset(); } }
@Override public final void request(long n) { if (SubscriptionHelper.validate(n)) { if (unbounded) { return; } if (get() == 0 && compareAndSet(0, 1)) { long r = requested; if (r != Long.MAX_VALUE) { r = BackpressureHelper.addCap(r, n); requested = r; if (r == Long.MAX_VALUE) { unbounded = true; } } Subscription a = actual; if (decrementAndGet() != 0) { drainLoop(); } if (a != null) { a.request(n); } return; } BackpressureHelper.add(missedRequested, n); drain(); } }
SubscriptionArbiter extends AtomicInteger implements Subscription { @Override public final void request(long n) { if (SubscriptionHelper.validate(n)) { if (unbounded) { return; } if (get() == 0 && compareAndSet(0, 1)) { long r = requested; if (r != Long.MAX_VALUE) { r = BackpressureHelper.addCap(r, n); requested = r; if (r == Long.MAX_VALUE) { unbounded = true; } } Subscription a = actual; if (decrementAndGet() != 0) { drainLoop(); } if (a != null) { a.request(n); } return; } BackpressureHelper.add(missedRequested, n); drain(); } } }
SubscriptionArbiter extends AtomicInteger implements Subscription { @Override public final void request(long n) { if (SubscriptionHelper.validate(n)) { if (unbounded) { return; } if (get() == 0 && compareAndSet(0, 1)) { long r = requested; if (r != Long.MAX_VALUE) { r = BackpressureHelper.addCap(r, n); requested = r; if (r == Long.MAX_VALUE) { unbounded = true; } } Subscription a = actual; if (decrementAndGet() != 0) { drainLoop(); } if (a != null) { a.request(n); } return; } BackpressureHelper.add(missedRequested, n); drain(); } } SubscriptionArbiter(); }
SubscriptionArbiter extends AtomicInteger implements Subscription { @Override public final void request(long n) { if (SubscriptionHelper.validate(n)) { if (unbounded) { return; } if (get() == 0 && compareAndSet(0, 1)) { long r = requested; if (r != Long.MAX_VALUE) { r = BackpressureHelper.addCap(r, n); requested = r; if (r == Long.MAX_VALUE) { unbounded = true; } } Subscription a = actual; if (decrementAndGet() != 0) { drainLoop(); } if (a != null) { a.request(n); } return; } BackpressureHelper.add(missedRequested, n); drain(); } } SubscriptionArbiter(); final void setSubscription(Subscription s); @Override final void request(long n); final void produced(long n); @Override void cancel(); final boolean isUnbounded(); final boolean isCancelled(); }
SubscriptionArbiter extends AtomicInteger implements Subscription { @Override public final void request(long n) { if (SubscriptionHelper.validate(n)) { if (unbounded) { return; } if (get() == 0 && compareAndSet(0, 1)) { long r = requested; if (r != Long.MAX_VALUE) { r = BackpressureHelper.addCap(r, n); requested = r; if (r == Long.MAX_VALUE) { unbounded = true; } } Subscription a = actual; if (decrementAndGet() != 0) { drainLoop(); } if (a != null) { a.request(n); } return; } BackpressureHelper.add(missedRequested, n); drain(); } } SubscriptionArbiter(); final void setSubscription(Subscription s); @Override final void request(long n); final void produced(long n); @Override void cancel(); final boolean isUnbounded(); final boolean isCancelled();  }