本文整理汇总了Java中reactor.core.CoreSubscriber.onNext方法的典型用法代码示例。如果您正苦于以下问题:Java CoreSubscriber.onNext方法的具体用法?Java CoreSubscriber.onNext怎么用?Java CoreSubscriber.onNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.CoreSubscriber
的用法示例。
在下文中一共展示了CoreSubscriber.onNext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateData
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
private void generateData(int elements) {
Random random = new Random();
SensorData data;
CoreSubscriber<SensorData> upstream;
for (long i = 0; i < elements; i++) {
data = new SensorData(i, random.nextFloat() * 100);
if (i % 2 == 0) {
upstream = sensorEven;
}
else {
upstream = sensorOdd;
}
upstream.onNext(data);
}
sensorEven.onComplete();
sensorEven = null;
sensorOdd.onComplete();
sensorOdd = null;
}
示例2: apply
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public CoreSubscriber<? super T> apply(Scannable scannable, CoreSubscriber<? super T> coreSubscriber) {
return new CoreSubscriber<T>() {
@Override
public void onSubscribe(Subscription subscription) {
if (subscribedOnce.getAndSet(true)) {
throw new NullPointerException("You cannot directly subscribe to a gRPC service multiple times " +
"concurrently. Use Flux.share() instead.");
} else {
coreSubscriber.onSubscribe(subscription);
}
}
@Override
public void onNext(T t) {
coreSubscriber.onNext(t);
}
@Override
public void onError(Throwable throwable) {
coreSubscriber.onError(throwable);
}
@Override
public void onComplete() {
coreSubscriber.onComplete();
}
};
}
示例3: serDrainLoop
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
void serDrainLoop(CoreSubscriber<? super T> actual) {
for (; ; ) {
if (cancelled) {
return;
}
boolean d;
Throwable e;
LinkedArrayNode<T> n;
synchronized (this) {
if (cancelled) {
return;
}
if (!missed) {
emitting = false;
return;
}
missed = false;
d = done;
e = error;
n = head;
head = null;
tail = null;
}
while (n != null) {
T[] arr = n.array;
int c = n.count;
for (int i = 0; i < c; i++) {
if (cancelled) {
return;
}
actual.onNext(arr[i]);
}
n = n.next;
}
if (cancelled) {
return;
}
if (e != null) {
actual.onError(e);
return;
}
else if (d) {
actual.onComplete();
return;
}
}
}