Package rx.internal.operators
Class OperatorReplay.ReplaySubscriber<T>
java.lang.Object
rx.Subscriber<T>
rx.internal.operators.OperatorReplay.ReplaySubscriber<T>
- All Implemented Interfaces:
Observer<T>
,Subscription
- Enclosing class:
OperatorReplay<T>
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final OperatorReplay.ReplayBuffer
<T> Holds notifications from upstream.(package private) boolean
Indicate that all request amounts should be considered.(package private) List
<OperatorReplay.InnerProducer<T>> The queue that holds producers with request changes that need to be coordinated.(package private) boolean
Contains either an onCompleted or an onError token from upstream.(package private) boolean
Guarded by this.(package private) static final OperatorReplay.InnerProducer[]
Indicates an empty array of inner producers.(package private) long
Contains the maximum element index the child Subscribers requested so far.(package private) long
Counts the outstanding upstream requests until the producer arrives.(package private) boolean
Guarded by this.(package private) final NotificationLite
<T> The notification-lite factory.(package private) Producer
The upstream producer.(package private) final OpenHashSet
<OperatorReplay.InnerProducer<T>> Tracks the subscribed producers.(package private) OperatorReplay.InnerProducer<T>[]
Contains a copy of the producers.(package private) long
Contains the number of modifications that the producersCache holds.(package private) long
Contains number of modifications to the producers set.(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) boolean
Indicates no further InnerProducers are accepted.(package private) static final OperatorReplay.InnerProducer[]
Indicates a terminated ReplaySubscriber. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
add
(OperatorReplay.InnerProducer<T> producer) Atomically try adding a new InnerProducer to this Subscriber or return false if this Subscriber was terminated.(package private) OperatorReplay.InnerProducer<T>[]
(package private) void
init()
Should be called after the constructor finished to setup nulling-out the current reference.(package private) void
makeRequest
(long maxTotalRequests, long previousTotalRequests) (package private) void
Coordinates the request amounts of various child Subscribers.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.(package private) void
remove
(OperatorReplay.InnerProducer<T> producer) Atomically removes the given producer from the producers array.(package private) void
replay()
Tries to replay the buffer contents to all known subscribers.void
If other subscriber is set (by calling constructorSubscriber(Subscriber)
orSubscriber(Subscriber, boolean)
) then this method callssetProducer
on the other subscriber.Methods inherited from class rx.Subscriber
add, isUnsubscribed, onStart, request, 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
-
buffer
Holds notifications from upstream. -
nl
The notification-lite factory. -
done
boolean doneContains either an onCompleted or an onError token from upstream. -
EMPTY
Indicates an empty array of inner producers. -
TERMINATED
Indicates a terminated ReplaySubscriber. -
terminated
volatile boolean terminatedIndicates no further InnerProducers are accepted. -
producers
Tracks the subscribed producers. Guarded by itself. -
producersCache
OperatorReplay.InnerProducer<T>[] producersCacheContains a copy of the producers. Modified only from the source side. -
producersVersion
volatile long producersVersionContains number of modifications to the producers set. -
producersCacheVersion
long producersCacheVersionContains the number of modifications that the producersCache holds. -
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. -
maxChildRequested
long maxChildRequestedContains the maximum element index the child Subscribers requested so far. Accessed while emitting is true. -
maxUpstreamRequested
long maxUpstreamRequestedCounts the outstanding upstream requests until the producer arrives. -
producer
The upstream producer. -
coordinationQueue
List<OperatorReplay.InnerProducer<T>> coordinationQueueThe queue that holds producers with request changes that need to be coordinated. -
coordinateAll
boolean coordinateAllIndicate that all request amounts should be considered.
-
-
Constructor Details
-
ReplaySubscriber
-
-
Method Details
-
init
void init()Should be called after the constructor finished to setup nulling-out the current reference. -
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
-
setProducer
Description copied from class:Subscriber
If other subscriber is set (by calling constructorSubscriber(Subscriber)
orSubscriber(Subscriber, boolean)
) then this method callssetProducer
on the other subscriber. If the other subscriber is not set and no requests have been made to this subscriber thenp.request(Long.MAX_VALUE)
is called. If the other subscriber is not set and some requests have been made to this subscriber thenp.request(n)
is called where n is the accumulated requests to this subscriber.- Overrides:
setProducer
in classSubscriber<T>
- Parameters:
p
- producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from
-
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>
-
manageRequests
Coordinates the request amounts of various child Subscribers. -
copyProducers
OperatorReplay.InnerProducer<T>[] copyProducers() -
makeRequest
void makeRequest(long maxTotalRequests, long previousTotalRequests) -
replay
void replay()Tries to replay the buffer contents to all known subscribers.
-