本文整理汇总了Java中java.util.concurrent.Flow.Subscription方法的典型用法代码示例。如果您正苦于以下问题:Java Flow.Subscription方法的具体用法?Java Flow.Subscription怎么用?Java Flow.Subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.Flow
的用法示例。
在下文中一共展示了Flow.Subscription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public final void onSubscribe(Flow.Subscription subscription) {
upstream = subscription;
if (subscription instanceof FusedSubscription) {
FusedSubscription<T> fs = (FusedSubscription<T>) subscription;
int m = fs.requestFusion(ANY);
if (m == SYNC) {
sourceFused = m;
queue = fs;
DONE.setRelease(this, true);
onStart();
return;
}
if (m == ASYNC) {
sourceFused = m;
queue = fs;
onStart();
fs.request(prefetch);
return;
}
}
int pf = prefetch;
if (pf == 1) {
queue = new SpscOneQueue<>();
} else {
queue = new SpscArrayQueue<>(pf);
}
onStart();
subscription.request(pf);
}
示例2: replaceRace
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void replaceRace() {
for (int i = 0; i < 1000; i++) {
AtomicReference<Flow.Subscription> ref = new AtomicReference<>();
BooleanSubscription d1 = new BooleanSubscription();
BooleanSubscription d2 = new BooleanSubscription();
Runnable r1 = () -> SubscriptionHelper.replace(ref, d1);
Runnable r2 = () -> SubscriptionHelper.replace(ref, d2);
TestHelper.race(r1, r2);
}
}
示例3: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
upstream = subscription;
if (subscription instanceof FusedSubscription) {
FusedSubscription fs = (FusedSubscription) subscription;
int m = fs.requestFusion(FusedSubscription.ANY);
if (m == FusedSubscription.SYNC) {
fusionMode = m;
queue = fs;
DONE.setRelease(this, true);
actual.onSubscribe(this);
drain();
return;
}
if (m == FusedSubscription.ASYNC) {
fusionMode = m;
queue = fs;
actual.onSubscribe(this);
subscription.request(prefetch);
return;
}
}
queue = new SpscArrayQueue<>(prefetch);
actual.onSubscribe(this);
subscription.request(prefetch);
}
示例4: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
if (SUBSCRIBERS.getAcquire(this) == TERMINATED) {
subscription.cancel();
} else {
subscription.request(Long.MAX_VALUE);
}
}
示例5: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public final void onSubscribe(Flow.Subscription subscription) {
upstream = subscription;
onStart();
int mc = maxConcurrency;
if (mc == Integer.MAX_VALUE) {
subscription.request(Long.MAX_VALUE);
} else {
subscription.request(mc);
}
}
示例6: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription s) {
if (remaining == 0L) {
s.cancel();
EmptySubscription.complete(actual);
} else {
this.upstream = s;
actual.onSubscribe(this);
}
}
示例7: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
if (this.subscription != null) {
throw new IllegalStateException();
}
this.subscription = subscription;
subscription.request(1);
}
示例8: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public void onSubscribe(Flow.Subscription subscription) {
arbiterReplace(subscription);
}
示例9: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
arbiterReplace(subscription);
}
示例10: IteratorCleanup
import java.util.concurrent.Flow; //导入方法依赖的package包/类
IteratorCleanup(Flow.Subscription upstream) {
this.upstream = upstream;
}
示例11: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
upstream = subscription;
actual.onSubscribe(this);
}
示例12: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
if (SubscriptionHelper.replace(this, subscription)) {
subscription.request(Long.MAX_VALUE);
}
}
示例13: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription s) {
this.s = s;
actual.onSubscribe(this);
}
示例14: LambdaConsumer
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public LambdaConsumer(CheckedConsumer<? super T> onNext, CheckedConsumer<? super Throwable> onError, CheckedRunnable onComplete, CheckedConsumer<? super Flow.Subscription> onSubscribe) {
this.onNext = onNext;
this.onError = onError;
this.onComplete = onComplete;
this.onSubscribe = onSubscribe;
}
示例15: onSubscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
subscribeMain(subscription);
}