2021-08-03 07:33:18 +00:00
|
|
|
package rx.internal.util;
|
|
|
|
|
2022-01-13 08:07:50 +00:00
|
|
|
import b.i.a.f.e.o.f;
|
2021-08-03 07:33:18 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import rx.Subscription;
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public final class SubscriptionList implements Subscription {
|
2021-12-02 18:53:44 +00:00
|
|
|
public List<Subscription> j;
|
|
|
|
public volatile boolean k;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
public SubscriptionList() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public SubscriptionList(Subscription subscription) {
|
|
|
|
LinkedList linkedList = new LinkedList();
|
2021-12-02 18:53:44 +00:00
|
|
|
this.j = linkedList;
|
2021-08-03 07:33:18 +00:00
|
|
|
linkedList.add(subscription);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SubscriptionList(Subscription... subscriptionArr) {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.j = new LinkedList(Arrays.asList(subscriptionArr));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Subscription subscription) {
|
|
|
|
if (!subscription.isUnsubscribed()) {
|
2021-12-02 18:53:44 +00:00
|
|
|
if (!this.k) {
|
2021-08-03 07:33:18 +00:00
|
|
|
synchronized (this) {
|
2021-12-02 18:53:44 +00:00
|
|
|
if (!this.k) {
|
|
|
|
List list = this.j;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (list == null) {
|
|
|
|
list = new LinkedList();
|
2021-12-02 18:53:44 +00:00
|
|
|
this.j = list;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
list.add(subscription);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscription
|
|
|
|
public boolean isUnsubscribed() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return this.k;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscription
|
|
|
|
public void unsubscribe() {
|
2021-12-02 18:53:44 +00:00
|
|
|
if (!this.k) {
|
2021-08-03 07:33:18 +00:00
|
|
|
synchronized (this) {
|
2021-12-02 18:53:44 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.k = true;
|
2022-03-07 09:34:54 +00:00
|
|
|
List<Subscription> list = this.j;
|
|
|
|
ArrayList arrayList = null;
|
2021-12-02 18:53:44 +00:00
|
|
|
this.j = null;
|
2022-03-07 09:34:54 +00:00
|
|
|
if (list != null) {
|
|
|
|
for (Subscription subscription : list) {
|
|
|
|
try {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
} catch (Throwable th) {
|
|
|
|
if (arrayList == null) {
|
|
|
|
arrayList = new ArrayList();
|
|
|
|
}
|
|
|
|
arrayList.add(th);
|
|
|
|
}
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
f.n1(arrayList);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|