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

The following examples show how to use reactor.core.publisher.Operators#terminate() . 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: ChannelOperations.java    From reactor-netty with Apache License 2.0 6 votes vote down vote up
/**
 * Final release/close (last packet)
 */
protected final void terminate() {
	if (rebind(connection)) {
		if (log.isTraceEnabled()) {
			log.trace(format(channel(), "Disposing ChannelOperation from a channel"),
					new Exception("ChannelOperation terminal stack"));
		}

		Operators.terminate(OUTBOUND_CLOSE, this);
		// Do not call directly inbound.onInboundComplete()
		// HttpClientOperations need to notify with error
		// when there is no response state
		onInboundComplete();
		afterInboundComplete();
		onTerminate.onComplete();
		listener.onStateChange(this, ConnectionObserver.State.DISCONNECTING);
	}
}
 
Example 2
Source File: MonoSendMany.java    From reactor-netty with Apache License 2.0 6 votes vote down vote up
void trySchedule(@Nullable Object data) {
	if (WIP.getAndIncrement(this) == 0) {
		try {
			if (eventLoop.inEventLoop()) {
				run();
				return;
			}
			eventLoop.execute(this);
		}
		catch (Throwable t) {
			if(Operators.terminate(SUBSCRIPTION, this)) {
				onInterruptionCleanup();
				actual.onError(Operators.onRejectedExecution(t, null, null, data, actual.currentContext()));
			}
		}
	}
}
 
Example 3
Source File: InheritableBaseSubscriber.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
@Override
public final void cancel() {
    if (Operators.terminate(S, this)) {
        try {
            hookOnCancel();
        } catch (Throwable throwable) {
            hookOnError(Operators.onOperatorError(subscription, throwable, currentContext()));
        } finally {
            safeHookFinally(SignalType.CANCEL);
        }
    }
}
 
Example 4
Source File: InheritableBaseSubscriber.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Override
public final void cancel() {
    if (Operators.terminate(S, this)) {
        try {
            hookOnCancel();
        } catch (Throwable throwable) {
            hookOnError(Operators.onOperatorError(subscription, throwable, currentContext()));
        } finally {
            safeHookFinally(SignalType.CANCEL);
        }
    }
}
 
Example 5
Source File: BlockingIterable.java    From rsocket-rpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(T t) {
  if (!queue.offer(t)) {
    Operators.terminate(S, this);

    onError(
        Operators.onOperatorError(
            null,
            Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL),
            t,
            currentContext()));
  } else {
    signalConsumer();
  }
}
 
Example 6
Source File: MonoSendMany.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void cancel() {
	if (!Operators.terminate(SUBSCRIPTION, this)) {
		return;
	}
	if (WIP.getAndIncrement(this) == 0) {
		onInterruptionCleanup();
	}
}
 
Example 7
Source File: MonoSendMany.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void operationComplete(ChannelFuture future) {
	if (Operators.terminate(SUBSCRIPTION, this)) {
		if (WIP.getAndIncrement(this) == 0) {
			onInterruptionCleanup();
		}
		//actual.onError(new AbortedException("Closed channel ["+ctx.channel().id().asShortText()+"] while sending operation active"));
		actual.onComplete();
	}
}
 
Example 8
Source File: MonoSendMany.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public boolean tryFailure(Throwable cause) {
	if (Operators.terminate(SUBSCRIPTION, this)) {
		if (WIP.getAndIncrement(this) == 0) {
			onInterruptionCleanup();
		}
		actual.onError(cause);
	}
	return true;
}
 
Example 9
Source File: BlockingIterable.java    From rsocket-rpc-java with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
  Operators.terminate(S, this);
  signalConsumer();
}
 
Example 10
Source File: ReconnectMono.java    From rsocket-java with Apache License 2.0 4 votes vote down vote up
void dispose() {
  if (Operators.terminate(S, this)) {
    this.doFinally();
  }
}
 
Example 11
Source File: DefaultRSocketClient.java    From rsocket-java with Apache License 2.0 4 votes vote down vote up
@Override
protected void doOnDispose() {
  Operators.terminate(S, this);
}