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 class
RefCountSubscription.InnerSubscription
The individual sub-subscriptions.(package private) static class
RefCountSubscription.State
-
Field Summary
Fields Modifier and Type Field Description private Subscription
actual
(package private) static RefCountSubscription.State
EMPTY_STATE
(package private) java.util.concurrent.atomic.AtomicReference<RefCountSubscription.State>
state
-
Constructor Summary
Constructors Constructor Description RefCountSubscription(Subscription s)
Creates aRefCountSubscription
by wrapping the given non-nullSubscription
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Subscription
get()
Returns a new sub-subscriptionboolean
isUnsubscribed()
Indicates whether thisSubscription
is currently unsubscribed.void
unsubscribe()
Stops the receipt of notifications on theSubscriber
that was registered when this Subscription was received.(package private) void
unsubscribeAChild()
private void
unsubscribeActualIfApplicable(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 aRefCountSubscription
by wrapping the given non-nullSubscription
.- Parameters:
s
- theSubscription
to wrap- Throws:
java.lang.IllegalArgumentException
- ifs
isnull
-
-
Method Detail
-
get
public Subscription get()
Returns a new sub-subscription- Returns:
- a new sub-subscription.
-
isUnsubscribed
public boolean isUnsubscribed()
Description copied from interface:Subscription
Indicates whether thisSubscription
is currently unsubscribed.- Specified by:
isUnsubscribed
in interfaceSubscription
- Returns:
true
if thisSubscription
is currently unsubscribed,false
otherwise
-
unsubscribe
public void unsubscribe()
Description copied from interface:Subscription
Stops the receipt of notifications on theSubscriber
that was registered when this Subscription was received.This allows unregistering an
Subscriber
before it has finished receiving all events (i.e. before onCompleted is called).- Specified by:
unsubscribe
in interfaceSubscription
-
unsubscribeActualIfApplicable
private void unsubscribeActualIfApplicable(RefCountSubscription.State state)
-
unsubscribeAChild
void unsubscribeAChild()
-
-