Java Code Examples for reactor.core.publisher.Operators#validate()
The following examples show how to use
reactor.core.publisher.Operators#validate() .
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: DeferredScalarSubscriber.java From akarnokd-misc with Apache License 2.0 | 6 votes |
@Override public void request(long n) { if (Operators.validate(n)) { for (; ; ) { int s = state; if (s == SDS_HAS_REQUEST_NO_VALUE || s == SDS_HAS_REQUEST_HAS_VALUE) { return; } if (s == SDS_NO_REQUEST_HAS_VALUE) { if (STATE.compareAndSet(this, SDS_NO_REQUEST_HAS_VALUE, SDS_HAS_REQUEST_HAS_VALUE)) { Subscriber<? super O> a = subscriber; a.onNext(value); a.onComplete(); } return; } if (STATE.compareAndSet(this, SDS_NO_REQUEST_NO_VALUE, SDS_HAS_REQUEST_NO_VALUE)) { return; } } } }
Example 2
Source File: ChannelSendOperator.java From java-technology-stack with MIT License | 5 votes |
@Override public final void onSubscribe(Subscription s) { if (Operators.validate(this.subscription, s)) { this.subscription = s; this.writeCompletionBarrier.connect(); s.request(1); } }
Example 3
Source File: UnboundedProcessor.java From rsocket-java with Apache License 2.0 | 5 votes |
@Override public void request(long n) { if (Operators.validate(n)) { Operators.addCap(REQUESTED, this, n); drain(); } }
Example 4
Source File: SimplePool.java From reactor-pool with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(upstream, s)) { this.upstream = s; actual.onSubscribe(this); this.start = pool.clock.millis(); } }
Example 5
Source File: DiscardOnCancelSubscriber.java From r2dbc-mysql with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = (S) s; this.actual.onSubscribe(this); } }
Example 6
Source File: AssertSubscriber.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void request(long n) { if (Operators.validate(n)) { if (establishedFusionMode != Fuseable.SYNC) { normalRequest(n); } } }
Example 7
Source File: ResolvingOperator.java From rsocket-java with Apache License 2.0 | 5 votes |
@Override public void request(long n) { if (Operators.validate(n)) { long r = this.requested; // volatile read beforehand if (r > STATE_SUBSCRIBED) { // works only in case onSubscribe has not happened long u; for (; ; ) { // normal CAS loop with overflow protection if (r == Long.MAX_VALUE) { // if r == Long.MAX_VALUE then we dont care and we can loose this // request just in case of racing return; } u = Operators.addCap(r, n); if (REQUESTED.compareAndSet(this, r, u)) { // Means increment happened before onSubscribe return; } else { // Means increment happened after onSubscribe // update new state to see what exactly happened (onSubscribe |cancel | requestN) r = this.requested; // check state (expect -1 | -2 to exit, otherwise repeat) if (r < 0) { break; } } } } if (r == STATE_CANCELLED) { // if canceled, just exit return; } // if onSubscribe -> subscription exists (and we sure of that because volatile read // after volatile write) so we can execute requestN on the subscription this.s.request(n); } }
Example 8
Source File: MetricsFuseableConditionalSubscriber.java From rsocket-rpc-java with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = (QueueSubscription<T>) s; this.start = System.nanoTime(); actual.onSubscribe(this); } }
Example 9
Source File: FluxReceive.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override public void request(long n) { if (Operators.validate(n)) { if (eventLoop.inEventLoop()) { this.receiverDemand = Operators.addCap(receiverDemand, n); drainReceiver(); } else { eventLoop.execute(() -> { this.receiverDemand = Operators.addCap(receiverDemand, n); drainReceiver(); }); } } }
Example 10
Source File: MetricsSubscriber.java From rsocket-rpc-java with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = s; this.start = System.nanoTime(); actual.onSubscribe(this); } }
Example 11
Source File: Http2ConnectionProvider.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(subscription, s)) { this.subscription = s; cancellations.add(this); if (!retried) { sink.onCancel(cancellations); } s.request(Long.MAX_VALUE); } }
Example 12
Source File: InheritableBaseSubscriber.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
@Override public final void request(long n) { if (Operators.validate(n)) { Subscription s = this.subscription; if (s != null) { s.request(n); } } }
Example 13
Source File: MetricsSubscriber.java From rsocket-rpc-java with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = s; this.start = System.nanoTime(); actual.onSubscribe(this); } }
Example 14
Source File: AssertSubscriber.java From RHub with Apache License 2.0 | 5 votes |
@Override public void request(long n) { if (Operators.validate(n)) { if (establishedFusionMode != Fuseable.SYNC) { normalRequest(n); } } }
Example 15
Source File: AbstractListenerReadPublisher.java From spring-analysis-note with MIT License | 5 votes |
@Override <T> void request(AbstractListenerReadPublisher<T> publisher, long n) { if (Operators.validate(n)) { Operators.addCap(DEMAND_FIELD_UPDATER, publisher, n); // Did a concurrent read transition to NO_DEMAND just before us? publisher.changeToDemandState(NO_DEMAND); } }
Example 16
Source File: RequestOperator.java From rsocket-java with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = s; if (s instanceof Fuseable.QueueSubscription) { this.qs = (Fuseable.QueueSubscription<Payload>) s; } this.actual.onSubscribe(this); } }
Example 17
Source File: AbstractListenerReadPublisher.java From spring-analysis-note with MIT License | 5 votes |
@Override <T> void request(AbstractListenerReadPublisher<T> publisher, long n) { if (Operators.validate(n)) { Operators.addCap(DEMAND_FIELD_UPDATER, publisher, n); publisher.changeToDemandState(this); } }
Example 18
Source File: NewConnectionProvider.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(subscription, s)) { this.subscription = s; sink.onCancel(this); s.request(Long.MAX_VALUE); } }
Example 19
Source File: DefaultRSocketClient.java From rsocket-java with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = s; this.actual.onSubscribe(this.second); } }
Example 20
Source File: WriteResultPublisher.java From java-technology-stack with MIT License | 4 votes |
@Override void request(WriteResultPublisher publisher, long n) { Operators.validate(n); }