public final class SequentialSubscription extends AtomicReference<Subscription> implements Subscription
Constructor and Description |
---|
SequentialSubscription()
Create an empty SequentialSubscription.
|
SequentialSubscription(Subscription initial)
Create a SequentialSubscription with the given initial Subscription.
|
Modifier and Type | Method and Description |
---|---|
Subscription |
current()
Returns the current contained Subscription (may be null).
|
boolean |
isUnsubscribed()
Indicates whether this
Subscription is currently unsubscribed. |
boolean |
replace(Subscription next)
Atomically replaces the contained Subscription to the provided next value but
does not unsubscribe the previous value or unsubscribes the next value if this
container is unsubscribed.
|
boolean |
replaceWeak(Subscription next)
Atomically tries to replace the contained Subscription to the provided next value but
does not unsubscribe the previous value or unsubscribes the next value if this container
is unsubscribed.
|
void |
unsubscribe()
Stops the receipt of notifications on the
Subscriber that was registered when this Subscription
was received. |
boolean |
update(Subscription next)
Atomically sets the contained Subscription to the provided next value and unsubscribes
the previous value or unsubscribes the next value if this container is unsubscribed.
|
boolean |
updateWeak(Subscription next)
Atomically tries to set the contained Subscription to the provided next value and unsubscribes
the previous value or unsubscribes the next value if this container is unsubscribed.
|
accumulateAndGet, compareAndSet, get, getAndAccumulate, getAndSet, getAndUpdate, lazySet, set, toString, updateAndGet, weakCompareAndSet
public SequentialSubscription()
public SequentialSubscription(Subscription initial)
initial
- the initial Subscription, may be nullpublic Subscription current()
(Remark: named as such because get() is final).
public boolean update(Subscription next)
(Remark: named as such because set() is final).
next
- the next Subscription to contain, may be nullpublic boolean replace(Subscription next)
next
- the next Subscription to contain, may be nullpublic boolean updateWeak(Subscription next)
Unlike update(Subscription)
, this doesn't retry if the replace failed
because a concurrent operation changed the underlying contained object.
next
- the next Subscription to contain, may be nullpublic boolean replaceWeak(Subscription next)
Unlike replace(Subscription)
, this doesn't retry if the replace failed
because a concurrent operation changed the underlying contained object.
next
- the next Subscription to contain, may be nullpublic 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.