mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-13 09:27:16 +01:00
48 lines
1.4 KiB
Java
48 lines
1.4 KiB
Java
package rx.subscriptions;
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import rx.Subscription;
|
|
import rx.functions.Action0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes12.dex */
|
|
public final class BooleanSubscription implements Subscription {
|
|
static final Action0 EMPTY_ACTION = new Action0() { // from class: rx.subscriptions.BooleanSubscription.1
|
|
@Override // rx.functions.Action0
|
|
public void call() {
|
|
}
|
|
};
|
|
final AtomicReference<Action0> actionRef;
|
|
|
|
public BooleanSubscription() {
|
|
this.actionRef = new AtomicReference<>();
|
|
}
|
|
|
|
public static BooleanSubscription create() {
|
|
return new BooleanSubscription();
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public boolean isUnsubscribed() {
|
|
return this.actionRef.get() == EMPTY_ACTION;
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public void unsubscribe() {
|
|
Action0 andSet;
|
|
Action0 action0 = this.actionRef.get();
|
|
Action0 action02 = EMPTY_ACTION;
|
|
if (action0 == action02 || (andSet = this.actionRef.getAndSet(action02)) == null || andSet == action02) {
|
|
return;
|
|
}
|
|
andSet.call();
|
|
}
|
|
|
|
public static BooleanSubscription create(Action0 action0) {
|
|
return new BooleanSubscription(action0);
|
|
}
|
|
|
|
private BooleanSubscription(Action0 action0) {
|
|
this.actionRef = new AtomicReference<>(action0);
|
|
}
|
|
}
|