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));
}
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));
}
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();
}
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);
}
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);
}
Aggregations