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


Java CoreSubscriber.onSubscribe方法代码示例

本文整理汇总了Java中reactor.core.CoreSubscriber.onSubscribe方法的典型用法代码示例。如果您正苦于以下问题:Java CoreSubscriber.onSubscribe方法的具体用法?Java CoreSubscriber.onSubscribe怎么用?Java CoreSubscriber.onSubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reactor.core.CoreSubscriber的用法示例。


在下文中一共展示了CoreSubscriber.onSubscribe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public final void subscribe(final CoreSubscriber<? super Void> s) {
	if(future.isDone()){
		if(future.isSuccess()){
			Operators.complete(s);
		}
		else{
			Operators.error(s, future.cause());
		}
		return;
	}

	FutureSubscription<F> fs = new FutureSubscription<>(future, s);
	s.onSubscribe(fs);
	future.addListener(fs);
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:17,代码来源:FutureMono.java

示例2: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super R> actual) {

	JoinSubscription<TLeft, TRight, TLeftEnd, TRightEnd, R> parent =
			new JoinSubscription<>(actual,
					leftEnd,
					rightEnd,
					resultSelector,
					queueSupplier.get());

	actual.onSubscribe(parent);

	LeftRightSubscriber left = new LeftRightSubscriber(parent, true);
	parent.cancellations.add(left);
	LeftRightSubscriber right = new LeftRightSubscriber(parent, false);
	parent.cancellations.add(right);

	source.subscribe(left);
	other.subscribe(right);
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:21,代码来源:FluxJoin.java

示例3: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super C> actual) {
	C buffer;

	try {
		buffer = Objects.requireNonNull(bufferSupplier.get(),
				"The bufferSupplier returned a null buffer");
	}
	catch (Throwable e) {
		Operators.error(actual, Operators.onOperatorError(e, actual.currentContext()));
		return;
	}

	BufferBoundaryMain<T, U, C> parent =
			new BufferBoundaryMain<>(
					source instanceof FluxInterval ?
							actual : Operators.serialize(actual),
					buffer, bufferSupplier);

	actual.onSubscribe(parent);

	other.subscribe(parent.other);

	source.subscribe(parent);
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:26,代码来源:FluxBufferBoundary.java

示例4: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
	Operators.MonoSubscriber<T, T>
			sds = new Operators.MonoSubscriber<>(actual);

	actual.onSubscribe(sds);

	if (sds.isCancelled()) {
		return;
	}

	try {
		T t = supplier.get();
		if (t == null) {
			sds.onComplete();
		}
		else {
			sds.complete(t);
		}
	}
	catch (Throwable e) {
		actual.onError(Operators.onOperatorError(e, actual.currentContext()));
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:25,代码来源:MonoSupplier.java

示例5: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super Flux<T>> actual) {
	WindowWhenMainSubscriber<T, U, V> main = new WindowWhenMainSubscriber<>(actual,
			start, end, processorQueueSupplier);
	actual.onSubscribe(main);

	if (main.cancelled) {
		return;
	}
	WindowWhenOpenSubscriber<T, U> os = new WindowWhenOpenSubscriber<>(main);

	if (WindowWhenMainSubscriber.BOUNDARY.compareAndSet(main,null, os)) {
		WindowWhenMainSubscriber.OPEN_WINDOW_COUNT.incrementAndGet(main);
		start.subscribe(os);
		source.subscribe(main);
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:18,代码来源:FluxWindowWhen.java

示例6: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super Long> actual) {
	Worker w = timedScheduler.createWorker();

	IntervalRunnable r = new IntervalRunnable(actual, w);

	actual.onSubscribe(r);

	try {
		w.schedulePeriodically(r, initialDelay, period, unit);
	}
	catch (RejectedExecutionException ree) {
		if (!r.cancelled) {
			actual.onError(Operators.onRejectedExecution(ree, r, null, null,
					actual.currentContext()));
		}
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:19,代码来源:FluxInterval.java

示例7: scanDelayRunnable

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Test
public void scanDelayRunnable() {
	CoreSubscriber<Long> actual = new LambdaMonoSubscriber<>(null, e -> {
	}, null, null);
	MonoDelay.MonoDelayRunnable test = new MonoDelay.MonoDelayRunnable(actual);

	actual.onSubscribe(test);

	assertThat(test.scan(Scannable.Attr.PARENT)).isNull();
	assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);

	assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
	test.request(1);
	test.run();
	assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
	assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:18,代码来源:MonoDelayTest.java

示例8: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
	Objects.requireNonNull(actual, "subscribe");
	if (once == 0 && ONCE.compareAndSet(this, 0, 1)) {

		actual.onSubscribe(this);
		this.actual = actual;
		if (cancelled) {
			this.actual = null;
		} else {
			drain();
		}
	} else {
		Operators.error(actual, new IllegalStateException("UnicastProcessor " +
				"allows only a single Subscriber"));
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:18,代码来源:UnicastProcessor.java

示例9: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
	T v = value;
	if (v == null) {
		ScheduledEmpty parent = new ScheduledEmpty(actual);
		actual.onSubscribe(parent);
		try {
			parent.setFuture(scheduler.schedule(parent));
		}
		catch (RejectedExecutionException ree) {
			if (parent.future != OperatorDisposables.DISPOSED) {
				actual.onError(Operators.onRejectedExecution(ree,
						actual.currentContext()));
			}
		}
	}
	else {
		actual.onSubscribe(new ScheduledScalar<>(actual, v, scheduler));
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:21,代码来源:FluxSubscribeOnValue.java

示例10: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
	Objects.requireNonNull(actual, "subscribe");
	EmitterInner<T> inner = new EmitterInner<>(actual, this);
	actual.onSubscribe(inner);

	if (inner.isCancelled()) {
		return;
	}

	if (add(inner)) {
		if (inner.isCancelled()) {
			remove(inner);
		}
		drain();
	}
	else {
		Throwable e = error;
		if (e != null) {
			inner.actual.onError(e);
		}
		else {
			inner.actual.onComplete();
		}
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:27,代码来源:EmitterProcessor.java

示例11: 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

示例12: subscribeOnlyOnceLifterErrorsWhenMultipleSubscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Test
public void subscribeOnlyOnceLifterErrorsWhenMultipleSubscribe() throws Exception {
    SubscribeOnlyOnceLifter<Object> op = new SubscribeOnlyOnceLifter<>();
    CoreSubscriber<Object> innerSub = mock(CoreSubscriber.class);
    Subscription subscription = mock(Subscription.class);

    CoreSubscriber<Object> outerSub = op.apply(null, innerSub);

    outerSub.onSubscribe(subscription);
    assertThatThrownBy(() -> outerSub.onSubscribe(subscription))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("cannot directly subscribe to a gRPC service multiple times");

    verify(innerSub, times(1)).onSubscribe(subscription);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:16,代码来源:SubscribeOnlyOnceTest.java

示例13: startReceiver

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
final void startReceiver(CoreSubscriber<? super Object> s) {
	if (receiver == null) {
		if (log.isDebugEnabled()) {
			log.debug("{} Subscribing inbound receiver [pending: {}, cancelled:{}, " +
							"inboundDone: {}]", channel.toString(), getPending(),
					isCancelled(),
					inboundDone);
		}
		if (inboundDone && getPending() == 0) {
			if (inboundError != null) {
				Operators.error(s, inboundError);
				return;
			}

			Operators.complete(s);
			return;
		}

		receiver = s;

		s.onSubscribe(this);
	}
	else {
		Operators.error(s,
				new IllegalStateException(
						"Only one connection receive subscriber allowed."));
	}
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:29,代码来源:FluxReceive.java

示例14: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
	PublishInner<T> inner = new PublishInner<>(actual);
	actual.onSubscribe(inner);
	for (; ; ) {
		if (inner.isCancelled()) {
			break;
		}

		PublishSubscriber<T> c = connection;
		if (c == null || c.isTerminated()) {
			PublishSubscriber<T> u = new PublishSubscriber<>(prefetch, this);
			if (!CONNECTION.compareAndSet(this, c, u)) {
				continue;
			}

			c = u;
		}

		if (c.add(inner)) {
			if (inner.isCancelled()) {
				c.remove(inner);
			}
			else {
				inner.parent = c;
			}
			c.drain();
			break;
		}
	}
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:32,代码来源:FluxPublish.java

示例15: subscribe

import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
	SampleFirstMain<T, U> main = new SampleFirstMain<>(actual, throttler);

	actual.onSubscribe(main);

	source.subscribe(main);
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:9,代码来源:FluxSampleFirst.java


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