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>
,java.io.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 java.util.concurrent.atomic.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static long
COMPLETE_MASK
Masks out the 2^63 bit indicating a completed state.protected org.reactivestreams.Subscriber<? super R>
downstream
The downstream consumer.protected long
produced
Number of values emitted so far.(package private) static long
REQUEST_MASK
Masks out the lower 63 bit holding the current request amount.private static long
serialVersionUID
protected org.reactivestreams.Subscription
upstream
The upstream subscription.protected R
value
The last value stored in case there is no request for it.
-
Constructor Summary
Constructors Constructor Description SinglePostCompleteSubscriber(org.reactivestreams.Subscriber<? super R> downstream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
protected void
complete(R n)
Signals the given value and an onComplete if the downstream is ready to receive the final value.protected void
onDrop(R n)
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)
.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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
downstream
protected final org.reactivestreams.Subscriber<? super R> downstream
The downstream consumer.
-
upstream
protected org.reactivestreams.Subscription upstream
The upstream subscription.
-
value
protected R value
The last value stored in case there is no request for it.
-
produced
protected long produced
Number of values emitted so far.
-
COMPLETE_MASK
static final long COMPLETE_MASK
Masks out the 2^63 bit indicating a completed state.- See Also:
- Constant Field Values
-
REQUEST_MASK
static final long REQUEST_MASK
Masks out the lower 63 bit holding the current request amount.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SinglePostCompleteSubscriber
public SinglePostCompleteSubscriber(org.reactivestreams.Subscriber<? super R> downstream)
-
-
Method Detail
-
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
protected final void complete(R n)
Signals the given value and an onComplete if the downstream is ready to receive the final value.- Parameters:
n
- the value to emit
-
onDrop
protected void onDrop(R n)
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
-
-