Skip to content

Commit 7b25665

Browse files
Merge pull request #1952 from zsxwing/remove-action-subscription
Remove ActionSubscription
2 parents 1b39e6b + 7337bb8 commit 7b25665

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

src/main/java/rx/subscriptions/Subscriptions.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,8 @@ public static Subscription empty() {
4646
* @return {@link Subscription}
4747
*/
4848
public static Subscription create(final Action0 unsubscribe) {
49-
return new ActionSubscription(unsubscribe);
49+
return BooleanSubscription.create(unsubscribe);
5050
}
51-
/**
52-
* Subscription that delegates the unsubscription action to an Action0 instance
53-
*/
54-
private static final class ActionSubscription implements Subscription {
55-
volatile Action0 actual;
56-
static final AtomicReferenceFieldUpdater<ActionSubscription, Action0> ACTUAL_UPDATER
57-
= AtomicReferenceFieldUpdater.newUpdater(ActionSubscription.class, Action0.class, "actual");
58-
public ActionSubscription(Action0 action) {
59-
this.actual = action != null ? action : Actions.empty();
60-
}
61-
@Override
62-
public boolean isUnsubscribed() {
63-
return actual == UNSUBSCRIBED_ACTION;
64-
}
65-
@Override
66-
public void unsubscribe() {
67-
Action0 a = ACTUAL_UPDATER.getAndSet(this, UNSUBSCRIBED_ACTION);
68-
a.call();
69-
}
70-
/** The no-op unique action indicating an unsubscribed state. */
71-
private static final Unsubscribed UNSUBSCRIBED_ACTION = new Unsubscribed();
72-
/** Naming classes helps with debugging. */
73-
private static final class Unsubscribed implements Action0 {
74-
@Override
75-
public void call() {
76-
77-
}
78-
}
79-
}
80-
8151

8252
/**
8353
* Converts a {@link Future} into a {@link Subscription} and cancels it when unsubscribed.

0 commit comments

Comments
 (0)