当前位置: 首页>>代码示例>>Java>>正文


Java CoreSubscriber.onNext方法代码示例

本文整理汇总了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;

}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:23,代码来源:CombinationTests.java

示例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();
        }
    };
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:30,代码来源:SubscribeOnlyOnceLifter.java

示例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;
		}
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:63,代码来源:SerializedSubscriber.java


注:本文中的reactor.core.CoreSubscriber.onNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。