public final class ScheduledAction extends AtomicReference<Thread> implements Runnable, Subscription
Runnable
that executes an Action0
and can be cancelled. The analog is the
Subscriber
in respect of an Observer
.Constructor and Description |
---|
ScheduledAction(Action0 action) |
ScheduledAction(Action0 action,
CompositeSubscription parent) |
ScheduledAction(Action0 action,
SubscriptionList parent) |
Modifier and Type | Method and Description |
---|---|
void |
add(Future<?> f)
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 this
ScheduledAction that will be unsubscribed
if the underlying action completes or the this scheduled action is cancelled. |
void |
addParent(CompositeSubscription parent)
Adds a parent
CompositeSubscription to this ScheduledAction so when the action is
cancelled or terminates, it can remove itself from this parent. |
void |
addParent(SubscriptionList parent)
Adds a parent
CompositeSubscription to this ScheduledAction so when the action is
cancelled or terminates, it can remove itself from this parent. |
boolean |
isUnsubscribed()
Indicates whether this
Subscription is currently unsubscribed. |
void |
run() |
void |
unsubscribe()
Stops the receipt of notifications on the
Subscriber that was registered when this Subscription
was received. |
accumulateAndGet, compareAndSet, get, getAndAccumulate, getAndSet, getAndUpdate, lazySet, set, toString, updateAndGet, weakCompareAndSet
public ScheduledAction(Action0 action)
public ScheduledAction(Action0 action, CompositeSubscription parent)
public ScheduledAction(Action0 action, SubscriptionList parent)
public boolean isUnsubscribed()
Subscription
Subscription
is currently unsubscribed.isUnsubscribed
in interface Subscription
true
if this Subscription
is currently unsubscribed, false
otherwisepublic 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 void add(Subscription s)
ScheduledAction
that will be unsubscribed
if the underlying action
completes or the this scheduled action is cancelled.s
- the Subscription to addpublic void add(Future<?> f)
f
- the future to addpublic void addParent(CompositeSubscription parent)
CompositeSubscription
to this ScheduledAction
so when the action is
cancelled or terminates, it can remove itself from this parent.parent
- the parent CompositeSubscription
to addpublic void addParent(SubscriptionList parent)
CompositeSubscription
to this ScheduledAction
so when the action is
cancelled or terminates, it can remove itself from this parent.parent
- the parent CompositeSubscription
to addCopyright © 2017. All rights reserved.