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 longMasks out the 2^63 bit indicating a completed state.protected final org.reactivestreams.Subscriber<? super R> The downstream consumer.protected longNumber of values emitted so far.(package private) static final longMasks out the lower 63 bit holding the current request amount.private static final longprotected org.reactivestreams.SubscriptionThe upstream subscription.protected RThe last value stored in case there is no request for it. -
Constructor Summary
ConstructorsConstructorDescriptionSinglePostCompleteSubscriber(org.reactivestreams.Subscriber<? super R> downstream) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()protected final voidSignals the given value and an onComplete if the downstream is ready to receive the final value.protected voidCalled in case of multiple calls to complete.voidonSubscribe(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 voidrequest(long n) Methods inherited from class 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, weakCompareAndSetVolatileMethods inherited from class Number
byteValue, shortValueMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:FlowableSubscriberImplementors 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:
onSubscribein interfaceFlowableSubscriber<T>- Specified by:
onSubscribein 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:
requestin interfaceorg.reactivestreams.Subscription
-
cancel
public void cancel()- Specified by:
cancelin interfaceorg.reactivestreams.Subscription
-