Search in sources :

Example 6 with SpscArrayQueue

use of io.reactivex.rxjava3.operators.SpscArrayQueue in project RxJava by ReactiveX.

the class QueueDrainHelperTest method drainMaxLoopMissingBackpressureWithResource.

@Test
public void drainMaxLoopMissingBackpressureWithResource() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    ts.onSubscribe(new BooleanSubscription());
    QueueDrain<Integer, Integer> qd = new QueueDrain<Integer, Integer>() {

        @Override
        public boolean cancelled() {
            return false;
        }

        @Override
        public boolean done() {
            return false;
        }

        @Override
        public Throwable error() {
            return null;
        }

        @Override
        public boolean enter() {
            return true;
        }

        @Override
        public long requested() {
            return 0;
        }

        @Override
        public long produced(long n) {
            return 0;
        }

        @Override
        public int leave(int m) {
            return 0;
        }

        @Override
        public boolean accept(Subscriber<? super Integer> a, Integer v) {
            return false;
        }
    };
    SpscArrayQueue<Integer> q = new SpscArrayQueue<>(32);
    q.offer(1);
    Disposable d = Disposable.empty();
    QueueDrainHelper.drainMaxLoop(q, ts, false, d, qd);
    ts.assertFailure(MissingBackpressureException.class);
    assertTrue(d.isDisposed());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) SpscArrayQueue(io.reactivex.rxjava3.operators.SpscArrayQueue) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 7 with SpscArrayQueue

use of io.reactivex.rxjava3.operators.SpscArrayQueue in project RxJava by ReactiveX.

the class QueueDrainHelperTest method drainMaxLoopDontAccept.

@Test
public void drainMaxLoopDontAccept() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    ts.onSubscribe(new BooleanSubscription());
    QueueDrain<Integer, Integer> qd = new QueueDrain<Integer, Integer>() {

        @Override
        public boolean cancelled() {
            return false;
        }

        @Override
        public boolean done() {
            return false;
        }

        @Override
        public Throwable error() {
            return null;
        }

        @Override
        public boolean enter() {
            return true;
        }

        @Override
        public long requested() {
            return 1;
        }

        @Override
        public long produced(long n) {
            return 0;
        }

        @Override
        public int leave(int m) {
            return 0;
        }

        @Override
        public boolean accept(Subscriber<? super Integer> a, Integer v) {
            return false;
        }
    };
    SpscArrayQueue<Integer> q = new SpscArrayQueue<>(32);
    q.offer(1);
    QueueDrainHelper.drainMaxLoop(q, ts, false, null, qd);
    ts.assertEmpty();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) SpscArrayQueue(io.reactivex.rxjava3.operators.SpscArrayQueue) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Aggregations

RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)7 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)7 SpscArrayQueue (io.reactivex.rxjava3.operators.SpscArrayQueue)7 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)7 Test (org.junit.Test)7