T
- the input and output typepublic final class OnSubscribePublishMulticast<T> extends AtomicInteger implements Observable.OnSubscribe<T>, Observer<T>, Subscription
The difference between this class and OperatorPublish is that this class doesn't consume the upstream if there are no child subscribers but waits for them to show up. Plus if the upstream source terminates, late subscribers will be immediately terminated with the same terminal event unlike OperatorPublish which just waits for the next connection.
The class extends AtomicInteger which is the work-in-progress gate for the drain-loop serializing subscriptions and child request changes.
Constructor and Description |
---|
OnSubscribePublishMulticast(int prefetch,
boolean delayError)
Constructor, initializes the fields
|
Modifier and Type | Method and Description |
---|---|
void |
call(Subscriber<? super T> t) |
boolean |
isUnsubscribed()
Indicates whether this
Subscription is currently unsubscribed. |
void |
onCompleted()
Notifies the Observer that the
Observable has finished sending push-based notifications. |
void |
onError(Throwable e)
Notifies the Observer that the
Observable has experienced an error condition. |
void |
onNext(T t)
Provides the Observer with a new item to observe.
|
Subscriber<T> |
subscriber()
Returns the input subscriber of this class that must be subscribed
to the upstream source.
|
void |
unsubscribe()
Stops the receipt of notifications on the
Subscriber that was registered when this Subscription
was received. |
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, intValue, lazySet, longValue, set, toString, updateAndGet, weakCompareAndSet
byteValue, shortValue
public OnSubscribePublishMulticast(int prefetch, boolean delayError)
prefetch
- the prefetch amount, > 0 requireddelayError
- delay the error delivery after the normal items?IllegalArgumentException
- if prefetch <= 0public void call(Subscriber<? super T> t)
call
in interface Action1<Subscriber<? super T>>
public void onNext(T t)
Observer
The Observable
may call this method 0 or more times.
The Observable
will not call this method again after it calls either Observer.onCompleted()
or
Observer.onError(java.lang.Throwable)
.
public void onError(Throwable e)
Observer
Observable
has experienced an error condition.
If the Observable
calls this method, it will not thereafter call Observer.onNext(T)
or
Observer.onCompleted()
.
public void onCompleted()
Observer
Observable
has finished sending push-based notifications.
The Observable
will not call this method if it calls Observer.onError(java.lang.Throwable)
.
onCompleted
in interface Observer<T>
public Subscriber<T> subscriber()
public void unsubscribe()
Subscription
Subscriber
that was registered when this Subscription
was received.
This allows deregistering an Subscriber
before it has finished receiving all events (i.e. before
onCompleted is called).
unsubscribe
in interface Subscription
public boolean isUnsubscribed()
Subscription
Subscription
is currently unsubscribed.isUnsubscribed
in interface Subscription
true
if this Subscription
is currently unsubscribed, false
otherwiseCopyright © 2017. All rights reserved.