Package rx.internal.operators
Class OperatorPublish.PublishSubscriber<T>
java.lang.Object
rx.Subscriber<T>
rx.internal.operators.OperatorPublish.PublishSubscriber<T>
- All Implemented Interfaces:
Observer<T>
,Subscription
- Enclosing class:
OperatorPublish<T>
static final class OperatorPublish.PublishSubscriber<T>
extends Subscriber<T>
implements Subscription
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final AtomicReference
<OperatorPublish.PublishSubscriber<T>> Holds onto the current connected PublishSubscriber.(package private) boolean
Guarded by this.(package private) static final OperatorPublish.InnerProducer[]
Indicates an empty array of inner producers.(package private) boolean
Guarded by this.(package private) final NotificationLite
<T> The notification-lite factory.(package private) final AtomicReference
<OperatorPublish.InnerProducer[]> Tracks the subscribed producers.Holds notifications from upstream.(package private) final AtomicBoolean
Atomically changed from false to true by connect to make sure the connection is only performed by one thread.(package private) Object
Contains either an onCompleted or an onError token from upstream.(package private) static final OperatorPublish.InnerProducer[]
Indicates a terminated PublishSubscriber. -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
add
(OperatorPublish.InnerProducer<T> producer) Atomically try adding a new InnerProducer to this Subscriber or return false if this Subscriber was terminated.(package private) boolean
checkTerminated
(Object term, boolean empty) Perform termination actions in case the source has terminated in some way and the queue has also become empty.(package private) void
dispatch()
The common serialization point of events arriving from upstream and child-subscribers requesting more.(package private) void
init()
Should be called after the constructor finished to setup nulling-out the current reference.void
Notifies the Observer that theObservable
has finished sending push-based notifications.void
Notifies the Observer that theObservable
has experienced an error condition.void
Provides the Observer with a new item to observe.void
onStart()
This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber.(package private) void
remove
(OperatorPublish.InnerProducer<T> producer) Atomically removes the given producer from the producers array.Methods inherited from class rx.Subscriber
add, isUnsubscribed, request, setProducer, unsubscribe
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface rx.Subscription
isUnsubscribed, unsubscribe
-
Field Details
-
queue
Holds notifications from upstream. -
nl
The notification-lite factory. -
current
Holds onto the current connected PublishSubscriber. -
terminalEvent
Contains either an onCompleted or an onError token from upstream. -
EMPTY
Indicates an empty array of inner producers. -
TERMINATED
Indicates a terminated PublishSubscriber. -
producers
Tracks the subscribed producers. -
shouldConnect
Atomically changed from false to true by connect to make sure the connection is only performed by one thread. -
emitting
boolean emittingGuarded by this. -
missed
boolean missedGuarded by this.
-
-
Constructor Details
-
PublishSubscriber
-
-
Method Details
-
init
void init()Should be called after the constructor finished to setup nulling-out the current reference. -
onStart
public void onStart()Description copied from class:Subscriber
This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber. Override this method to add any useful initialization to your subscription, for instance to initiate backpressure.- Overrides:
onStart
in classSubscriber<T>
-
onNext
Description copied from interface:Observer
Provides the Observer with a new item to observe.The
Observable
may call this method 0 or more times.The
Observable
will not call this method again after it calls eitherObserver.onCompleted()
orObserver.onError(java.lang.Throwable)
. -
onError
Description copied from interface:Observer
Notifies the Observer that theObservable
has experienced an error condition.If the
Observable
calls this method, it will not thereafter callObserver.onNext(T)
orObserver.onCompleted()
. -
onCompleted
public void onCompleted()Description copied from interface:Observer
Notifies the Observer that theObservable
has finished sending push-based notifications.The
Observable
will not call this method if it callsObserver.onError(java.lang.Throwable)
.- Specified by:
onCompleted
in interfaceObserver<T>
-
add
Atomically try adding a new InnerProducer to this Subscriber or return false if this Subscriber was terminated.- Parameters:
producer
- the producer to add- Returns:
- true if succeeded, false otherwise
-
remove
Atomically removes the given producer from the producers array.- Parameters:
producer
- the producer to remove
-
checkTerminated
Perform termination actions in case the source has terminated in some way and the queue has also become empty.- Parameters:
term
- the terminal event (a NotificationLite.error or completed)empty
- set to true if the queue is empty- Returns:
- true if there is indeed a terminal condition
-
dispatch
void dispatch()The common serialization point of events arriving from upstream and child-subscribers requesting more.
-