Package rx.internal.schedulers
Class ScheduledAction
- All Implemented Interfaces:
Serializable
,Runnable
,Subscription
public final class ScheduledAction
extends AtomicReference<Thread>
implements Runnable, Subscription
A
Runnable
that executes an Action0
and can be cancelled. The analog is the
Subscriber
in respect of an Observer
.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) final class
Cancels 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 final class
Remove a child subscription from a composite when unsubscribing.(package private) static final class
Remove a child subscription from a composite when unsubscribing. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Action0
(package private) final SubscriptionList
private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionScheduledAction
(Action0 action) ScheduledAction
(Action0 action, SubscriptionList parent) ScheduledAction
(Action0 action, CompositeSubscription parent) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given Future to the unsubscription composite in order to support cancelling the underlying task in the executor framework.void
add
(Subscription s) Adds a general Subscription to thisScheduledAction
that will be unsubscribed if the underlyingaction
completes or the this scheduled action is cancelled.void
addParent
(SubscriptionList parent) Adds a parentCompositeSubscription
to thisScheduledAction
so when the action is cancelled or terminates, it can remove itself from this parent.void
addParent
(CompositeSubscription parent) Adds a parentCompositeSubscription
to thisScheduledAction
so when the action is cancelled or terminates, it can remove itself from this parent.boolean
Indicates whether thisSubscription
is currently unsubscribed.void
run()
(package private) void
signalError
(Throwable ie) void
Stops the receipt of notifications on theSubscriber
that 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 Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
cancel
-
action
-
-
Constructor Details
-
ScheduledAction
-
ScheduledAction
-
ScheduledAction
-
-
Method Details
-
run
public void run() -
signalError
-
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
-
add
Adds a general Subscription to thisScheduledAction
that will be unsubscribed if the underlyingaction
completes or the this scheduled action is cancelled.- Parameters:
s
- the Subscription to add
-
add
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
Adds a parentCompositeSubscription
to thisScheduledAction
so when the action is cancelled or terminates, it can remove itself from this parent.- Parameters:
parent
- the parentCompositeSubscription
to add
-
addParent
Adds a parentCompositeSubscription
to thisScheduledAction
so when the action is cancelled or terminates, it can remove itself from this parent.- Parameters:
parent
- the parentCompositeSubscription
to add
-