Package rx.internal.schedulers
Class ScheduledAction
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<java.lang.Thread>
-
- rx.internal.schedulers.ScheduledAction
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Runnable,Subscription
public final class ScheduledAction extends java.util.concurrent.atomic.AtomicReference<java.lang.Thread> implements java.lang.Runnable, Subscription
ARunnablethat executes anAction0and can be cancelled. The analog is theSubscriberin respect of anObserver.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classScheduledAction.FutureCompleterCancels the captured future if the caller of the call method is not the same as the runner of the outer ScheduledAction to prevent unnecessary self-interrupting if the unsubscription happens from the same thread.(package private) static classScheduledAction.RemoverRemove a child subscription from a composite when unsubscribing.(package private) static classScheduledAction.Remover2Remove a child subscription from a composite when unsubscribing.
-
Field Summary
Fields Modifier and Type Field Description (package private) Action0action(package private) SubscriptionListcancelprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description ScheduledAction(Action0 action)ScheduledAction(Action0 action, SubscriptionList parent)ScheduledAction(Action0 action, CompositeSubscription parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.util.concurrent.Future<?> f)Adds the given Future to the unsubscription composite in order to support cancelling the underlying task in the executor framework.voidadd(Subscription s)Adds a general Subscription to thisScheduledActionthat will be unsubscribed if the underlyingactioncompletes or the this scheduled action is cancelled.voidaddParent(SubscriptionList parent)Adds a parentCompositeSubscriptionto thisScheduledActionso when the action is cancelled or terminates, it can remove itself from this parent.voidaddParent(CompositeSubscription parent)Adds a parentCompositeSubscriptionto thisScheduledActionso when the action is cancelled or terminates, it can remove itself from this parent.booleanisUnsubscribed()Indicates whether thisSubscriptionis currently unsubscribed.voidrun()(package private) voidsignalError(java.lang.Throwable ie)voidunsubscribe()Stops the receipt of notifications on theSubscriberthat was registered when this Subscription was received.-
Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
cancel
final SubscriptionList cancel
-
action
final Action0 action
-
-
Constructor Detail
-
ScheduledAction
public ScheduledAction(Action0 action)
-
ScheduledAction
public ScheduledAction(Action0 action, CompositeSubscription parent)
-
ScheduledAction
public ScheduledAction(Action0 action, SubscriptionList parent)
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
signalError
void signalError(java.lang.Throwable ie)
-
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
-
add
public void add(Subscription s)
Adds a general Subscription to thisScheduledActionthat will be unsubscribed if the underlyingactioncompletes or the this scheduled action is cancelled.- Parameters:
s- the Subscription to add
-
add
public void add(java.util.concurrent.Future<?> f)
Adds the given Future to the unsubscription composite in order to support cancelling the underlying task in the executor framework.- Parameters:
f- the future to add
-
addParent
public void addParent(CompositeSubscription parent)
Adds a parentCompositeSubscriptionto thisScheduledActionso when the action is cancelled or terminates, it can remove itself from this parent.- Parameters:
parent- the parentCompositeSubscriptionto add
-
addParent
public void addParent(SubscriptionList parent)
Adds a parentCompositeSubscriptionto thisScheduledActionso when the action is cancelled or terminates, it can remove itself from this parent.- Parameters:
parent- the parentCompositeSubscriptionto add
-
-