@Override public void onNext(T t) { queue.offer(t); drain(); }
@Override public void onNext(T t) { queue.offer(t); drain(); }
ScanSeedSubscriber(Subscriber<? super R> actual, BiFunction<R, ? super T, R> accumulator, R value, int prefetch) { this.downstream = actual; this.accumulator = accumulator; this.value = value; this.prefetch = prefetch; this.limit = prefetch - (prefetch >> 2); this.queue = new SpscArrayQueue<R>(prefetch); this.queue.offer(value); this.requested = new AtomicLong(); }
void complete(UnicastProcessor<T> w) { queue.offer(new SubjectWork<T>(w, false)); if (enter()) { drainLoop(); } }
@Override public void run() { if (cancelled) { terminated = true; disposeTimer(); } queue.offer(NEXT); if (enter()) { drainLoop(); } }
void open(B b) { queue.offer(new WindowOperation<T, B>(null, b)); if (enter()) { drainLoop(); } }
void complete(UnicastSubject<T> w) { queue.offer(new SubjectWork<T>(w, false)); if (enter()) { drainLoop(); } }
@Override public void run() { if (cancelled) { terminated = true; dispose(); } queue.offer(NEXT); if (enter()) { drainLoop(); } }
void open(B b) { queue.offer(new WindowOperation<Object, B>(null, b)); if (enter()) { drainLoop(); } }
@Override public void onComplete() { U b; synchronized (this) { b = buffer; buffer = null; } queue.offer(b); done = true; if (enter()) { QueueDrainHelper.drainMaxLoop(queue, downstream, false, this, this); } w.dispose(); }
@Override public void run() { UnicastSubject<T> w = UnicastSubject.create(bufferSize); SubjectWork<T> sw = new SubjectWork<T>(w, true); if (!cancelled) { queue.offer(sw); } if (enter()) { drainLoop(); } }
@Override public void onNext(T t) { if (queue.offer(t)) { drain(); } else { upstream.cancel(); onError(new MissingBackpressureException("Queue full?!")); } }
@Override public void onNext(T t) { if (!queue.offer(t)) { upstream.cancel(); onError(new MissingBackpressureException("queue full?!")); return; } drain(); }
@Override public void run() { UnicastProcessor<T> w = UnicastProcessor.<T>create(bufferSize); SubjectWork<T> sw = new SubjectWork<T>(w, true); if (!cancelled) { queue.offer(sw); } if (enter()) { drainLoop(); } }
void close(OperatorWindowBoundaryCloseObserver<T, V> w) { resources.delete(w); queue.offer(new WindowOperation<T, Object>(w.w, null)); if (enter()) { drainLoop(); } } }
@Override public void onNext(T t) { if (!queue.offer(t)) { upstream.cancel(); onError(new MissingBackpressureException("queue full?!")); return; } drain(); }
void close(OperatorWindowBoundaryCloseSubscriber<T, V> w) { resources.delete(w); queue.offer(new WindowOperation<T, B>(w.w, null)); if (enter()) { drainLoop(); } } }
@Test public void orderedSlowPathNonEmptyQueue() { TestObserver<Integer> to = new TestObserver<Integer>(); Disposable d = Disposables.empty(); QueueDrainObserver<Integer, Integer, Integer> qd = createOrdered(to, d); to.onSubscribe(Disposables.empty()); qd.queue.offer(0); qd.onNext(1); to.assertValuesOnly(0, 1); }
@Test public void orderedSlowPathNonEmptyQueue() { TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1); Disposable d = Disposables.empty(); QueueDrainSubscriber<Integer, Integer, Integer> qd = createOrdered(ts, d); ts.onSubscribe(new BooleanSubscription()); qd.queue.offer(0); qd.requested(2); qd.onNext(1); ts.assertValuesOnly(0, 1); }
@Test(timeout = 10000) public void cancelNoConcurrentClean() { TestObserver<Integer> to = new TestObserver<Integer>(); ConcatMapSingleMainObserver<Integer, Integer> operator = new ConcatMapSingleMainObserver<Integer, Integer>( to, Functions.justFunction(Single.<Integer>never()), 16, ErrorMode.IMMEDIATE); operator.onSubscribe(Disposables.empty()); operator.queue.offer(1); operator.getAndIncrement(); to.cancel(); assertFalse(operator.queue.isEmpty()); operator.addAndGet(-2); operator.dispose(); assertTrue(operator.queue.isEmpty()); }