@Override public void onNext(T t) { if (establishedFusionMode == Fuseable.ASYNC) { while (true) { t = qs.poll(); if (t == null) { break; } valueCount++; if (valuesStorage) { List<T> nextValuesSnapshot; while (true) { nextValuesSnapshot = values; nextValuesSnapshot.add(t); if (NEXT_VALUES.compareAndSet(this, nextValuesSnapshot, nextValuesSnapshot)) { break; } } } } } else { valueCount++; if (valuesStorage) { List<T> nextValuesSnapshot; while (true) { nextValuesSnapshot = values; nextValuesSnapshot.add(t); if (NEXT_VALUES.compareAndSet(this, nextValuesSnapshot, nextValuesSnapshot)) { break; } } } } }
@Override @SuppressWarnings("unchecked") public void onSubscribe(Subscription s) { subscriptionCount++; int requestMode = requestedFusionMode; if (requestMode >= 0) { if (!setWithoutRequesting(s)) { if (!isCancelled()) { errors.add(new IllegalStateException("Subscription already set: " + subscriptionCount)); } } else { if (s instanceof Fuseable.QueueSubscription) { this.qs = (Fuseable.QueueSubscription<T>) s; int m = qs.requestFusion(requestMode); establishedFusionMode = m; if (m == Fuseable.SYNC) { while (true) { T v = qs.poll(); if (v == null) { onComplete(); break; } onNext(v); } } else { requestDeferred(); } } else { requestDeferred(); } } } else { if (!set(s)) { if (!isCancelled()) { errors.add(new IllegalStateException("Subscription already set: " + subscriptionCount)); } } } }