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

The following examples show how to use reactor.core.publisher.Operators#setOnce() . 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: InheritableBaseSubscriber.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
    if (Operators.setOnce(S, this, s)) {
        try {
            hookOnSubscribe(s);
        } catch (Throwable throwable) {
            onError(Operators.onOperatorError(s, throwable, currentContext()));
        }
    }
}
 
Example 2
Source File: InheritableBaseSubscriber.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
    if (Operators.setOnce(S, this, s)) {
        try {
            hookOnSubscribe(s);
        } catch (Throwable throwable) {
            onError(Operators.onOperatorError(s, throwable, currentContext()));
        }
    }
}
 
Example 3
Source File: MonoSendMany.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
	if (Operators.setOnce(SUBSCRIPTION, this, s)) {
		if (s instanceof QueueSubscription) {
			@SuppressWarnings("unchecked") QueueSubscription<I> f =
					(QueueSubscription<I>) s;

			int m = f.requestFusion(Fuseable.ANY/* | Fuseable.THREAD_BARRIER*/);

			if (m == Fuseable.SYNC) {
				sourceMode = Fuseable.SYNC;
				queue = f;
				terminalSignal = Completion.INSTANCE;
				actual.onSubscribe(this);
				trySchedule(null);
				return;
			}
			if (m == Fuseable.ASYNC) {
				sourceMode = Fuseable.ASYNC;
				queue = f;
				actual.onSubscribe(this);
				s.request(MAX_SIZE);
				return;
			}
		}

		queue = Queues.<I>get(MAX_SIZE).get();
		actual.onSubscribe(this);
		s.request(MAX_SIZE);
	}
	else {
		queue = Queues.<I>empty().get();
	}
}
 
Example 4
Source File: BlockingIterable.java    From rsocket-rpc-java with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
  if (Operators.setOnce(S, this, s)) {
    s.request(unboundedOrPrefetch(batchSize));
  }
}
 
Example 5
Source File: ChannelOperations.java    From reactor-netty with Apache License 2.0 4 votes vote down vote up
@Override
public final void onSubscribe(Subscription s) {
	if (Operators.setOnce(OUTBOUND_CLOSE, this, s)) {
		s.request(Long.MAX_VALUE);
	}
}
 
Example 6
Source File: ReconnectMono.java    From rsocket-java with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
  if (Operators.setOnce(S, this, s)) {
    s.request(Long.MAX_VALUE);
  }
}
 
Example 7
Source File: DefaultRSocketClient.java    From rsocket-java with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
  if (Operators.setOnce(S, this, s)) {
    s.request(Long.MAX_VALUE);
  }
}