T
- the value typeS
- the per-subscriber user-defined state typepublic static final class AbstractOnSubscribe.SubscriptionState<T,S>
extends java.lang.Object
AbstractOnSubscribe
operation. It supports phasing
and counts the number of times a value was requested by the downstream.Modifier and Type | Method and Description |
---|---|
protected boolean |
accept()
Emits the
onNext and/or the terminal value to the actual subscriber. |
void |
advancePhase()
Advance the current phase by 1.
|
void |
advancePhaseBy(int amount)
Advance the current phase by the given amount (can be negative).
|
long |
calls() |
protected void |
free()
Release the state if there are no more interest in it and it is not in use.
|
void |
onCompleted()
Call this method to send an
onCompleted to the subscriber and terminate all further
activities. |
void |
onError(java.lang.Throwable e)
Call this method to send an
onError to the subscriber and terminate all further activities. |
void |
onNext(T value)
Call this method to offer the next
onNext value for the subscriber. |
int |
phase() |
void |
phase(int newPhase)
Sets a new phase value.
|
S |
state() |
void |
stop()
Signals that there won't be any further events.
|
protected boolean |
stopRequested() |
protected void |
terminate()
Terminates the state immediately and calls
AbstractOnSubscribe.onTerminated(S) with the custom
state. |
protected boolean |
use()
Request the state to be used by
onNext or returns false if the downstream has
unsubscribed. |
protected boolean |
verify()
Verify if the
next() generated an event or requested a stop. |
public S state()
AbstractOnSubscribe.onSubscribe(rx.Subscriber<? super T>)
public int phase()
public void phase(int newPhase)
newPhase
- public void advancePhase()
public void advancePhaseBy(int amount)
amount
- the amount to advance the phasepublic long calls()
AbstractOnSubscribe.next(rx.observables.AbstractOnSubscribe.SubscriptionState<T, S>)
was called so far, starting at 0 for the
very first callpublic void onNext(T value)
onNext
value for the subscriber.value
- the value to onNext
java.lang.IllegalStateException
- if there is a value already offered but not taken or a terminal state
is reachedpublic void onError(java.lang.Throwable e)
onError
to the subscriber and terminate all further activities.
If there is a pending onNext
, that value is emitted to the subscriber followed by this
exception.e
- the exception to deliver to the clientjava.lang.IllegalStateException
- if the terminal state has been reached alreadypublic void onCompleted()
onCompleted
to the subscriber and terminate all further
activities. If there is a pending onNext
, that value is emitted to the subscriber followed by
this exception.java.lang.IllegalStateException
- if the terminal state has been reached alreadypublic void stop()
protected boolean accept()
onNext
and/or the terminal value to the actual subscriber.true
if the event was a terminal eventprotected boolean verify()
next()
generated an event or requested a stop.protected boolean stopRequested()
next()
requested a stopprotected boolean use()
onNext
or returns false
if the downstream has
unsubscribed.true
if the state can be used exclusivelyIllegalStateEception
protected void free()
protected void terminate()
AbstractOnSubscribe.onTerminated(S)
with the custom
state.