Top Description Fields Constructors Methods
rx.internal.subscriptions

public final Class SequentialSubscription

extends AtomicReference<Subscription>
implements Subscription
Class Inheritance
All Implemented Interfaces
rx.Subscription
Imports
java.util.concurrent.atomic.AtomicReference, rx.Subscription, rx.subscriptions.Subscriptions

A container of a Subscription that supports operations of SerialSubscription and MultipleAssignmentSubscription via methods (update, replace) and extends AtomicReference to reduce allocation count (beware the API leak of AtomicReference!).
Since
1.1.9

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public
SequentialSubscription()

Create an empty SequentialSubscription.

public
SequentialSubscription(Subscription
the initial Subscription, may be null
initial
)

Create a SequentialSubscription with the given initial Subscription.

Method Summary

Modifier and TypeMethod and Description
public Subscription

Returns:

the current contained Subscription (may be null)
current
()

Returns the current contained Subscription (may be null).

public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public boolean

Returns:

true if the update succeeded, false if the container was unsubscribed
replace
(Subscription
the next Subscription to contain, may be null
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.

public boolean

Returns:

true if the update succeeded, false if the container was unsubscribed
replaceWeak
(Subscription
the next Subscription to contain, may be null
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.

public void
unsubscribe()

Implements rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
public boolean

Returns:

true if the update succeeded, false if the container was unsubscribed
update
(Subscription
the next Subscription to contain, may be null
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.

public boolean

Returns:

true if the update succeeded, false if the container was unsubscribed
updateWeak
(Subscription
the next Subscription to contain, may be null
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.

Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

Constructor Detail

SequentialSubscriptionback to summary
public SequentialSubscription()

Create an empty SequentialSubscription.

SequentialSubscriptionback to summary
public SequentialSubscription(Subscription initial)

Create a SequentialSubscription with the given initial Subscription.

Parameters
initial:Subscription

the initial Subscription, may be null

Method Detail

currentback to summary
public Subscription current()

Returns the current contained Subscription (may be null).

(Remark: named as such because get() is final).

Returns:Subscription

the current contained Subscription (may be null)

isUnsubscribedback to summary
public boolean isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Doc from rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.

Returns:boolean

true if this Subscription is currently unsubscribed, false otherwise

Annotations
@Override
replaceback to summary
public 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.

Parameters
next:Subscription

the next Subscription to contain, may be null

Returns:boolean

true if the update succeeded, false if the container was unsubscribed

replaceWeakback to summary
public 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.

Unlike replace(Subscription), this doesn't retry if the replace failed because a concurrent operation changed the underlying contained object.

Parameters
next:Subscription

the next Subscription to contain, may be null

Returns:boolean

true if the update succeeded, false if the container was unsubscribed

unsubscribeback to summary
public void unsubscribe()

Implements rx.Subscription.unsubscribe.

Doc from rx.Subscription.unsubscribe.

Stops the receipt of notifications on the 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).

Annotations
@Override
updateback to summary
public 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.

(Remark: named as such because set() is final).

Parameters
next:Subscription

the next Subscription to contain, may be null

Returns:boolean

true if the update succeeded, false if the container was unsubscribed

updateWeakback to summary
public 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.

Unlike update(Subscription), this doesn't retry if the replace failed because a concurrent operation changed the underlying contained object.

Parameters
next:Subscription

the next Subscription to contain, may be null

Returns:boolean

true if the update succeeded, false if the container was unsubscribed