Java Code Examples for reactor.core.Fuseable#ASYNC
The following examples show how to use
reactor.core.Fuseable#ASYNC .
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: FluxPublish.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void onNext(T t) { if (done) { if (t != null) { Operators.onNextDropped(t, currentContext()); } return; } if (sourceMode == Fuseable.ASYNC) { drain(); return; } if (!queue.offer(t)) { Throwable ex = Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, currentContext()); if (!Exceptions.addThrowable(ERROR, this, ex)) { Operators.onErrorDroppedMulticast(ex); return; } done = true; } drain(); }
Example 2
Source File: FluxMetricsFuseable.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void onNext(T t) { if (this.mode == Fuseable.ASYNC) { actual.onNext(null); return; } if (done) { recordMalformed(commonTags, registry); Operators.onNextDropped(t, actual.currentContext()); return; } //record the delay since previous onNext/onSubscribe. This also records the count. long last = this.lastNextEventNanos; this.lastNextEventNanos = clock.monotonicTime(); this.onNextIntervalTimer.record(lastNextEventNanos - last, TimeUnit.NANOSECONDS); actual.onNext(t); }
Example 3
Source File: FluxFlatMap.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.setOnce(S, this, s)) { if (s instanceof Fuseable.QueueSubscription) { @SuppressWarnings("unchecked") Fuseable.QueueSubscription<R> f = (Fuseable.QueueSubscription<R>) s; int m = f.requestFusion(Fuseable.ANY | Fuseable.THREAD_BARRIER); if (m == Fuseable.SYNC) { sourceMode = Fuseable.SYNC; queue = f; done = true; parent.drain(null); return; } if (m == Fuseable.ASYNC) { sourceMode = Fuseable.ASYNC; queue = f; } // NONE is just fall-through as the queue will be created on demand } s.request(Operators.unboundedOrPrefetch(prefetch)); } }
Example 4
Source File: FluxPublishMulticast.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void onNext(T t) { if (done) { Operators.onNextDropped(t, context); return; } if (sourceMode != Fuseable.ASYNC) { if (!queue.offer(t)) { onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, context)); return; } } drain(); }
Example 5
Source File: DefaultStepVerifierBuilder.java From reactor-core with Apache License 2.0 | 6 votes |
boolean serializeDrainAndSubscriptionEvent() { int missed = WIP.incrementAndGet(this); if (missed != 1) { return true; } for (; ; ) { if(onSubscriptionLoop()){ return true; } if(establishedFusionMode == Fuseable.ASYNC) { drainAsyncLoop(); } missed = WIP.addAndGet(this, -missed); if (missed == 0) { break; } } return false; }
Example 6
Source File: AssertSubscriber.java From reactor-core with Apache License 2.0 | 5 votes |
/** * Assert that the fusion mode was granted. * * @return this */ public final AssertSubscriber<T> assertFusionEnabled() { if (establishedFusionMode != Fuseable.SYNC && establishedFusionMode != Fuseable.ASYNC) { throw new AssertionError("Fusion was not enabled"); } return this; }
Example 7
Source File: EmitterProcessor.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void onNext(T t) { if (done) { Operators.onNextDropped(t, currentContext()); return; } if (sourceMode == Fuseable.ASYNC) { drain(); return; } Objects.requireNonNull(t, "onNext"); Queue<T> q = queue; if (q == null) { if (Operators.setOnce(S, this, Operators.emptySubscription())) { q = Queues.<T>get(prefetch).get(); queue = q; } else { for (; ; ) { if (isDisposed()) { return; } q = queue; if (q != null) { break; } } } } while (!q.offer(t)) { LockSupport.parkNanos(10); } drain(); }
Example 8
Source File: FluxGroupBy.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public int requestFusion(int requestedMode) { if ((requestedMode & Fuseable.ASYNC) != 0) { outputFused = true; return Fuseable.ASYNC; } return Fuseable.NONE; }
Example 9
Source File: FluxGroupBy.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public int requestFusion(int requestedMode) { if ((requestedMode & Fuseable.ASYNC) != 0) { enableAsyncFusion = true; return Fuseable.ASYNC; } return Fuseable.NONE; }
Example 10
Source File: FluxPublishOn.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = s; if (s instanceof QueueSubscription) { @SuppressWarnings("unchecked") QueueSubscription<T> f = (QueueSubscription<T>) s; int m = f.requestFusion(Fuseable.ANY | Fuseable.THREAD_BARRIER); if (m == Fuseable.SYNC) { sourceMode = Fuseable.SYNC; queue = f; done = true; actual.onSubscribe(this); return; } if (m == Fuseable.ASYNC) { sourceMode = Fuseable.ASYNC; queue = f; actual.onSubscribe(this); s.request(Operators.unboundedOrPrefetch(prefetch)); return; } } queue = queueSupplier.get(); actual.onSubscribe(this); s.request(Operators.unboundedOrPrefetch(prefetch)); } }
Example 11
Source File: FluxWindowPredicate.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public int requestFusion(int requestedMode) { if ((requestedMode & Fuseable.ASYNC) != 0) { enableOperatorFusion = true; return Fuseable.ASYNC; } return Fuseable.NONE; }
Example 12
Source File: FluxWindowPredicate.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public int requestFusion(int requestedMode) { if ((requestedMode & Fuseable.ASYNC) != 0) { outputFused = true; return Fuseable.ASYNC; } return Fuseable.NONE; }
Example 13
Source File: DefaultStepVerifierBuilder.java From reactor-core with Apache License 2.0 | 5 votes |
static String formatFusionMode(int m) { switch (m) { case Fuseable.ANY: return "(any)"; case Fuseable.SYNC: return "(sync)"; case Fuseable.ASYNC: return "(async)"; case Fuseable.NONE: return "none"; case Fuseable.THREAD_BARRIER: return "(thread-barrier)"; } return "" + m; }
Example 14
Source File: FluxTake.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public T poll() { if (done) { return null; } long r = remaining; T v = qs.poll(); if (r == 0L) { done = true; if (inputMode == Fuseable.ASYNC) { qs.cancel(); actual.onComplete(); } return null; } if (v != null) { remaining = --r; if (r == 0L) { if (!done) { done = true; if (inputMode == Fuseable.ASYNC) { qs.cancel(); actual.onComplete(); } } } } return v; }
Example 15
Source File: FluxConcatMap.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void onNext(T t) { if (sourceMode == Fuseable.ASYNC) { drain(); } else if (!queue.offer(t)) { Context ctx = actual.currentContext(); onError(Operators.onOperatorError(s, Exceptions.failWithOverflow(Exceptions.BACKPRESSURE_ERROR_QUEUE_FULL), t, ctx)); Operators.onDiscard(t, ctx); } else { drain(); } }
Example 16
Source File: EmitterProcessor.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(final Subscription s) { if (Operators.setOnce(S, this, s)) { if (s instanceof Fuseable.QueueSubscription) { @SuppressWarnings("unchecked") Fuseable.QueueSubscription<T> f = (Fuseable.QueueSubscription<T>) s; int m = f.requestFusion(Fuseable.ANY); if (m == Fuseable.SYNC) { sourceMode = m; queue = f; drain(); return; } else if (m == Fuseable.ASYNC) { sourceMode = m; queue = f; s.request(Operators.unboundedOrPrefetch(prefetch)); return; } } queue = Queues.<T>get(prefetch).get(); s.request(Operators.unboundedOrPrefetch(prefetch)); } }
Example 17
Source File: DeferredScalarSubscriber.java From akarnokd-misc with Apache License 2.0 | 5 votes |
@Override public int requestFusion(int requestedMode) { if ((requestedMode & Fuseable.ASYNC) != 0) { outputFused = OUTPUT_NO_VALUE; return Fuseable.ASYNC; } return Fuseable.NONE; }
Example 18
Source File: ParallelSource.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = s; if (s instanceof Fuseable.QueueSubscription) { @SuppressWarnings("unchecked") Fuseable.QueueSubscription<T> qs = (Fuseable.QueueSubscription<T>) s; int m = qs.requestFusion(Fuseable.ANY | Fuseable.THREAD_BARRIER); if (m == Fuseable.SYNC) { sourceMode = m; queue = qs; done = true; setupSubscribers(); drain(); return; } else if (m == Fuseable.ASYNC) { sourceMode = m; queue = qs; setupSubscribers(); s.request(Operators.unboundedOrPrefetch(prefetch)); return; } } queue = queueSupplier.get(); setupSubscribers(); s.request(Operators.unboundedOrPrefetch(prefetch)); } }
Example 19
Source File: AssertSubscriber.java From RHub with Apache License 2.0 | 5 votes |
/** * Assert that the fusion mode was granted. * * @return this */ public final AssertSubscriber<T> assertFusionEnabled() { if (establishedFusionMode != Fuseable.SYNC && establishedFusionMode != Fuseable.ASYNC) { throw new AssertionError("Fusion was not enabled"); } return this; }
Example 20
Source File: ReactorClientStreamObserverAndPublisher.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public int requestFusion(int requestedMode) { if ((requestedMode & Fuseable.ASYNC) != 0) { outputFused = true; return Fuseable.ASYNC; } return Fuseable.NONE; }