Package rx.subscriptions
Class RefCountSubscription
- java.lang.Object
-
- rx.subscriptions.RefCountSubscription
-
- All Implemented Interfaces:
Subscription
public final class RefCountSubscription extends java.lang.Object implements Subscription
Keeps track of the sub-subscriptions and unsubscribes the underlying subscription once all sub-subscriptions have unsubscribed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classRefCountSubscription.InnerSubscriptionThe individual sub-subscriptions.(package private) static classRefCountSubscription.State
-
Field Summary
Fields Modifier and Type Field Description private Subscriptionactual(package private) static RefCountSubscription.StateEMPTY_STATE(package private) java.util.concurrent.atomic.AtomicReference<RefCountSubscription.State>state
-
Constructor Summary
Constructors Constructor Description RefCountSubscription(Subscription s)Creates aRefCountSubscriptionby wrapping the given non-nullSubscription.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Subscriptionget()Returns a new sub-subscriptionbooleanisUnsubscribed()Indicates whether thisSubscriptionis currently unsubscribed.voidunsubscribe()Stops the receipt of notifications on theSubscriberthat was registered when this Subscription was received.(package private) voidunsubscribeAChild()private voidunsubscribeActualIfApplicable(RefCountSubscription.State state)
-
-
-
Field Detail
-
actual
private final Subscription actual
-
EMPTY_STATE
static final RefCountSubscription.State EMPTY_STATE
-
state
final java.util.concurrent.atomic.AtomicReference<RefCountSubscription.State> state
-
-
Constructor Detail
-
RefCountSubscription
public RefCountSubscription(Subscription s)
Creates aRefCountSubscriptionby wrapping the given non-nullSubscription.- Parameters:
s- theSubscriptionto wrap- Throws:
java.lang.IllegalArgumentException- ifsisnull
-
-
Method Detail
-
get
public Subscription get()
Returns a new sub-subscription- Returns:
- a new sub-subscription.
-
isUnsubscribed
public boolean isUnsubscribed()
Description copied from interface:SubscriptionIndicates whether thisSubscriptionis currently unsubscribed.- Specified by:
isUnsubscribedin interfaceSubscription- Returns:
trueif thisSubscriptionis currently unsubscribed,falseotherwise
-
unsubscribe
public void unsubscribe()
Description copied from interface:SubscriptionStops the receipt of notifications on theSubscriberthat was registered when this Subscription was received.This allows unregistering an
Subscriberbefore it has finished receiving all events (i.e. before onCompleted is called).- Specified by:
unsubscribein interfaceSubscription
-
unsubscribeActualIfApplicable
private void unsubscribeActualIfApplicable(RefCountSubscription.State state)
-
unsubscribeAChild
void unsubscribeAChild()
-
-