Class SinglePostCompleteSubscriber<T,R>
java.lang.Object
java.lang.Number
java.util.concurrent.atomic.AtomicLong
io.reactivex.rxjava3.internal.subscribers.SinglePostCompleteSubscriber<T,R>
- Type Parameters:
T
- the input value typeR
- the output value type
- All Implemented Interfaces:
FlowableSubscriber<T>
,Serializable
,org.reactivestreams.Subscriber<T>
,org.reactivestreams.Subscription
- Direct Known Subclasses:
FlowableConcatWithMaybe.ConcatWithSubscriber
,FlowableConcatWithSingle.ConcatWithSubscriber
,FlowableMapNotification.MapNotificationSubscriber
,FlowableMaterialize.MaterializeSubscriber
,FlowableOnErrorReturn.OnErrorReturnSubscriber
public abstract class SinglePostCompleteSubscriber<T,R>
extends AtomicLong
implements FlowableSubscriber<T>, org.reactivestreams.Subscription
Relays signals from upstream according to downstream requests and allows
signalling a final value followed by onComplete in a backpressure-aware manner.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final long
Masks out the 2^63 bit indicating a completed state.protected final org.reactivestreams.Subscriber
<? super R> The downstream consumer.protected long
Number of values emitted so far.(package private) static final long
Masks out the lower 63 bit holding the current request amount.private static final long
protected org.reactivestreams.Subscription
The upstream subscription.protected R
The last value stored in case there is no request for it. -
Constructor Summary
ConstructorsConstructorDescriptionSinglePostCompleteSubscriber
(org.reactivestreams.Subscriber<? super R> downstream) -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
protected final void
Signals the given value and an onComplete if the downstream is ready to receive the final value.protected void
Called in case of multiple calls to complete.void
onSubscribe
(org.reactivestreams.Subscription s) Implementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)
is established before callingSubscription.request(long)
.final void
request
(long n) Methods inherited from class java.util.concurrent.atomic.AtomicLong
accumulateAndGet, addAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAcquire, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, getOpaque, getPlain, incrementAndGet, intValue, lazySet, longValue, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
Methods inherited from class java.lang.Number
byteValue, shortValue
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.reactivestreams.Subscriber
onComplete, onError, onNext
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
downstream
The downstream consumer. -
upstream
protected org.reactivestreams.Subscription upstreamThe upstream subscription. -
value
The last value stored in case there is no request for it. -
produced
protected long producedNumber of values emitted so far. -
COMPLETE_MASK
static final long COMPLETE_MASKMasks out the 2^63 bit indicating a completed state.- See Also:
-
REQUEST_MASK
static final long REQUEST_MASKMasks out the lower 63 bit holding the current request amount.- See Also:
-
-
Constructor Details
-
SinglePostCompleteSubscriber
-
-
Method Details
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s) Description copied from interface:FlowableSubscriber
Implementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)
is established before callingSubscription.request(long)
. In practice this means no initialization should happen after therequest()
call and additional behavior is thread safe in respect toonNext
.- Specified by:
onSubscribe
in interfaceFlowableSubscriber<T>
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
complete
Signals the given value and an onComplete if the downstream is ready to receive the final value.- Parameters:
n
- the value to emit
-
onDrop
Called in case of multiple calls to complete.- Parameters:
n
- the value dropped
-
request
public final void request(long n) - Specified by:
request
in interfaceorg.reactivestreams.Subscription
-
cancel
public void cancel()- Specified by:
cancel
in interfaceorg.reactivestreams.Subscription
-