本文整理了Java中org.reactivestreams.Subscription
类的一些代码示例,展示了Subscription
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subscription
类的具体详情如下:
包路径:org.reactivestreams.Subscription
类名称:Subscription
[英]A Subscription represents a one-to-one lifecycle of a Subscriber subscribing to a Publisher.
It can only be used once by a single Subscriber.
It is used to both signal desire for data and cancel demand (and allow resource cleanup).
[中]
代码示例来源:origin: ReactiveX/RxJava
/**
* Called once the single upstream Subscription is set via onSubscribe.
*/
protected void onStart() {
upstream.get().request(Long.MAX_VALUE);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (terminalEvent.get() != null) {
s.cancel();
return;
}
s.request(Long.MAX_VALUE);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (done || cancelled) {
s.cancel();
} else {
s.request(Long.MAX_VALUE);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
if (value != null) {
upstream.get().cancel();
onError(new IndexOutOfBoundsException("More than one element received"));
return;
}
value = t;
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (SubscriptionHelper.validate(this.upstream, s)) {
this.upstream = s;
downstream.onSubscribe(this);
if (other.get() == null) {
sampler.subscribe(new SamplerSubscriber<T>(this));
s.request(Long.MAX_VALUE);
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (SubscriptionHelper.validate(this.upstream, s)) {
this.upstream = s;
downstream.onSubscribe(this);
s.request(Long.MAX_VALUE);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void cancel() {
upstream.cancel();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable t) {
receiver.cancel();
downstream.onError(t);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
long r = remaining;
if (r > 0L) {
remaining = --r;
downstream.onNext(t);
if (r == 0L) {
upstream.cancel();
downstream.onComplete();
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (SubscriptionHelper.validate(this.upstream, s)) {
if (remaining == 0L) {
s.cancel();
EmptySubscription.complete(downstream);
} else {
this.upstream = s;
downstream.onSubscribe(this);
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onComplete() {
receiver.cancel();
downstream.onComplete();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
if (skip == size()) {
downstream.onNext(poll());
} else {
upstream.request(1);
}
offer(t);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
if (!done && remaining-- > 0) {
boolean stop = remaining == 0;
downstream.onNext(t);
if (stop) {
upstream.cancel();
onComplete();
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (SubscriptionHelper.validate(this.upstream, s)) {
this.upstream = s;
downstream.onSubscribe(this);
s.request(Long.MAX_VALUE);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void cancel() {
if (!cancelled) {
cancelled = true;
upstream.cancel();
if (getAndIncrement() == 0) {
current.lazySet(null);
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
if (done) {
return;
}
if (sourceMode == QueueSubscription.NONE && !queue.offer(t)) {
upstream.get().cancel();
onError(new MissingBackpressureException());
return;
}
drain();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (SubscriptionHelper.validate(this.upstream, s)) {
this.upstream = s;
downstream.onSubscribe(this);
s.request(Long.MAX_VALUE);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (done) {
s.cancel();
return;
}
s.request(Long.MAX_VALUE);
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Cancels the upstream's Subscription.
*/
protected final void cancel() {
Subscription s = this.upstream;
this.upstream = SubscriptionHelper.CANCELLED;
s.cancel();
}
/**
代码示例来源:origin: ReactiveX/RxJava
void error(Throwable e) {
Exceptions.throwIfFatal(e);
done = true;
upstream.cancel();
downstream.onError(e);
}
内容来源于网络,如有侵权,请联系作者删除!