Search in sources :

Example 26 with Subscription

use of org.reactivestreams.Subscription in project cyclops by aol.

the class AbstractCollectionXTest method subscribeErrorEmpty.

@Test
public void subscribeErrorEmpty() {
    List result = new ArrayList<>();
    Subscription s = of().forEachSubscribe(i -> result.add(i), e -> e.printStackTrace());
    s.request(1l);
    assertThat(result.size(), equalTo(0));
    s.request(1l);
    assertThat(result.size(), equalTo(0));
    s.request(1l);
    assertThat(result.size(), equalTo(0));
}
Also used : Arrays.asList(java.util.Arrays.asList) Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Example 27 with Subscription

use of org.reactivestreams.Subscription in project cyclops by aol.

the class AbstractCollectionXTest method subscribe.

@Test
public void subscribe() {
    List<Integer> result = new ArrayList<>();
    Subscription s = of(1, 2, 3).forEachSubscribe(i -> result.add(i));
    s.request(1l);
    assertThat(result.size(), equalTo(1));
    s.request(1l);
    assertThat(result.size(), equalTo(2));
    s.request(1l);
    assertThat(result.size(), equalTo(3));
    assertThat(result, hasItems(1, 2, 3));
}
Also used : Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Example 28 with Subscription

use of org.reactivestreams.Subscription in project reactor-netty by reactor.

the class ChannelOperations method onComplete.

@Override
public final void onComplete() {
    Subscription s = OUTBOUND_CLOSE.getAndSet(this, Operators.cancelledSubscription());
    if (s == Operators.cancelledSubscription() || isDisposed()) {
        return;
    }
    onOutboundComplete();
}
Also used : Subscription(org.reactivestreams.Subscription)

Example 29 with Subscription

use of org.reactivestreams.Subscription in project reactor-netty by reactor.

the class ChannelOperations method onError.

@Override
public final void onError(Throwable t) {
    Subscription s = OUTBOUND_CLOSE.getAndSet(this, Operators.cancelledSubscription());
    if (s == Operators.cancelledSubscription() || isDisposed()) {
        if (log.isDebugEnabled()) {
            log.error("An outbound error could not be processed", t);
        }
        return;
    }
    onOutboundError(t);
}
Also used : Subscription(org.reactivestreams.Subscription)

Example 30 with Subscription

use of org.reactivestreams.Subscription in project reactor-core by reactor.

the class LambdaMonoSubscriber method onError.

@Override
public final void onError(Throwable t) {
    Subscription s = S.getAndSet(this, Operators.cancelledSubscription());
    if (s == Operators.cancelledSubscription()) {
        Operators.onErrorDropped(t, Context.empty());
        return;
    }
    doError(t);
}
Also used : Subscription(org.reactivestreams.Subscription)

Aggregations

Subscription (org.reactivestreams.Subscription)627 Test (org.junit.Test)506 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)158 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)131 ArrayList (java.util.ArrayList)117 AtomicReference (java.util.concurrent.atomic.AtomicReference)105 List (java.util.List)80 FluxOperatorTest (reactor.test.publisher.FluxOperatorTest)74 Subscriber (org.reactivestreams.Subscriber)68 AtomicLong (java.util.concurrent.atomic.AtomicLong)56 Assert (org.junit.Assert)56 Arrays (java.util.Arrays)43 BaseSequentialTest (com.oath.cyclops.streams.BaseSequentialTest)42 Vector (cyclops.data.Vector)39 ReactiveSeq (cyclops.reactive.ReactiveSeq)39 Executor (java.util.concurrent.Executor)38 Spouts (cyclops.reactive.Spouts)36 Arrays.asList (java.util.Arrays.asList)36 Executors (java.util.concurrent.Executors)35 StepVerifier (reactor.test.StepVerifier)34