Java Code Examples for reactor.core.publisher.Operators#complete()

The following examples show how to use reactor.core.publisher.Operators#complete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FutureMono.java    From reactor-netty with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public final void subscribe(final CoreSubscriber<? super Void> s) {
	if(future.isDone()){
		if(future.isSuccess()){
			Operators.complete(s);
		}
		else{
			Operators.error(s, FutureSubscription.wrapError(future.cause()));
		}
		return;
	}

	FutureSubscription<F> fs = new FutureSubscription<>(future, s);
	// Returned value is deliberately ignored
	future.addListener(fs);
	s.onSubscribe(fs);
}
 
Example 2
Source File: SimplePool.java    From reactor-pool with Apache License 2.0 5 votes vote down vote up
@Override
public void subscribe(CoreSubscriber<? super Void> actual) {
    QueuePooledRef<T> slot = slotRef.getAndSet(null);
    if (slot == null || !slot.markReleased()) {
        Operators.complete(actual);
    }
    else {
        QueuePoolRecyclerInner<T> qpr = new QueuePoolRecyclerInner<>(actual, slot);
        source.subscribe(qpr);
    }
}
 
Example 3
Source File: FutureMono.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void subscribe(CoreSubscriber<? super Void> s) {
	F f;
	try {
		f = deferredFuture.get();
	}
	catch(Throwable t) {
		Operators.error(s, t);
		return;
	}

	if (f == null) {
		Operators.error(s,
				Operators.onOperatorError(new NullPointerException(
						"Deferred supplied null"), s.currentContext()));
		return;
	}

	if (f.isDone()) {
		if (f.isSuccess()) {
			Operators.complete(s);
		}
		else {
			Operators.error(s, FutureSubscription.wrapError(f.cause()));
		}
		return;
	}

	FutureSubscription<F> fs = new FutureSubscription<>(f, s);
	s.onSubscribe(fs);
	// Returned value is deliberately ignored
	f.addListener(fs);
}
 
Example 4
Source File: FluxReceive.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void subscribe(CoreSubscriber<? super Object> s) {
	if (once == 0 && ONCE.compareAndSet(this, 0, 1)) {
		if (log.isDebugEnabled()) {
			log.debug(format(channel, "Subscribing inbound receiver [pending: {}, cancelled:{}, " +
							"inboundDone: {}]"),
					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 {
		if (inboundDone && getPending() == 0) {
			if (inboundError != null) {
				Operators.error(s, inboundError);
				return;
			}

			Operators.complete(s);
		}
		else {
			Operators.error(s,
					new IllegalStateException(
							"Only one connection receive subscriber allowed."));
		}
	}
}