discord-jadx/app/src/main/java/j0/l/a/z0.java

199 lines
6.0 KiB
Java
Raw Normal View History

2021-11-08 18:25:28 +00:00
package j0.l.a;
2021-06-27 20:44:35 +00:00
2022-01-27 00:50:41 +00:00
import b.i.a.f.e.o.f;
2021-11-08 18:25:28 +00:00
import j0.l.c.m;
2021-12-17 22:03:14 +00:00
import j0.l.e.i;
import j0.l.e.n.c;
import j0.l.e.o.n;
import j0.l.e.o.y;
2021-11-08 18:25:28 +00:00
import j0.o.l;
2021-06-27 20:44:35 +00:00
import java.util.Queue;
import java.util.concurrent.atomic.AtomicLong;
import rx.Observable;
import rx.Scheduler;
import rx.Subscriber;
import rx.exceptions.MissingBackpressureException;
import rx.functions.Action0;
2022-03-02 20:59:20 +00:00
/* compiled from: OperatorObserveOn.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public final class z0<T> implements Observable.b<T, T> {
2021-12-17 22:03:14 +00:00
public final Scheduler j;
public final boolean k;
public final int l;
2021-06-27 20:44:35 +00:00
2022-03-02 20:59:20 +00:00
/* compiled from: OperatorObserveOn.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public static final class a<T> extends Subscriber<T> implements Action0 {
2021-12-17 22:03:14 +00:00
public final Subscriber<? super T> j;
public final Scheduler.Worker k;
public final boolean l;
public final Queue<Object> m;
public final int n;
public volatile boolean o;
2021-06-27 20:44:35 +00:00
public final AtomicLong p = new AtomicLong();
2021-12-17 22:03:14 +00:00
public final AtomicLong q = new AtomicLong();
public Throwable r;
/* renamed from: s reason: collision with root package name */
2022-03-30 16:43:10 +00:00
public long f3766s;
2021-06-27 20:44:35 +00:00
public a(Scheduler scheduler, Subscriber<? super T> subscriber, boolean z2, int i) {
2021-12-17 22:03:14 +00:00
this.j = subscriber;
this.k = scheduler.a();
this.l = z2;
i = i <= 0 ? i.j : i;
this.n = i - (i >> 2);
2021-06-27 20:44:35 +00:00
if (y.b()) {
2021-12-17 22:03:14 +00:00
this.m = new n(i);
2021-06-27 20:44:35 +00:00
} else {
2021-12-17 22:03:14 +00:00
this.m = new c(i);
2021-06-27 20:44:35 +00:00
}
2022-03-02 20:59:20 +00:00
request(i);
2021-06-27 20:44:35 +00:00
}
public boolean a(boolean z2, boolean z3, Subscriber<? super T> subscriber, Queue<Object> queue) {
if (subscriber.isUnsubscribed()) {
queue.clear();
return true;
} else if (!z2) {
return false;
} else {
2021-12-17 22:03:14 +00:00
if (!this.l) {
Throwable th = this.r;
2021-06-27 20:44:35 +00:00
if (th != null) {
queue.clear();
try {
subscriber.onError(th);
return true;
} finally {
}
} else if (!z3) {
return false;
} else {
try {
subscriber.onCompleted();
return true;
} finally {
}
}
} else if (!z3) {
return false;
} else {
2021-12-17 22:03:14 +00:00
Throwable th2 = this.r;
2022-03-02 20:59:20 +00:00
try {
if (th2 != null) {
2021-06-27 20:44:35 +00:00
subscriber.onError(th2);
2022-03-02 20:59:20 +00:00
} else {
subscriber.onCompleted();
2021-06-27 20:44:35 +00:00
}
2022-03-02 20:59:20 +00:00
return false;
} finally {
2021-06-27 20:44:35 +00:00
}
}
}
}
public void b() {
2021-12-17 22:03:14 +00:00
if (this.q.getAndIncrement() == 0) {
this.k.a(this);
2021-06-27 20:44:35 +00:00
}
}
@Override // rx.functions.Action0
public void call() {
int i;
2022-03-30 16:43:10 +00:00
long j = this.f3766s;
2021-12-17 22:03:14 +00:00
Queue<Object> queue = this.m;
Subscriber<? super T> subscriber = this.j;
2021-06-27 20:44:35 +00:00
long j2 = 1;
do {
2021-12-17 22:03:14 +00:00
long j3 = this.p.get();
2021-06-27 20:44:35 +00:00
while (true) {
i = (j3 > j ? 1 : (j3 == j ? 0 : -1));
if (i == 0) {
break;
}
2021-12-17 22:03:14 +00:00
boolean z2 = this.o;
2021-06-27 20:44:35 +00:00
Object poll = queue.poll();
boolean z3 = poll == null;
if (!a(z2, z3, subscriber, queue)) {
if (z3) {
break;
}
subscriber.onNext((Object) e.b(poll));
j++;
2022-03-02 20:59:20 +00:00
if (j == this.n) {
2022-01-27 00:50:41 +00:00
j3 = f.U0(this.p, j);
2021-06-27 20:44:35 +00:00
request(j);
j = 0;
}
} else {
return;
}
}
2021-12-17 22:03:14 +00:00
if (i != 0 || !a(this.o, queue.isEmpty(), subscriber, queue)) {
2022-03-30 16:43:10 +00:00
this.f3766s = j;
2021-12-17 22:03:14 +00:00
j2 = this.q.addAndGet(-j2);
2021-06-27 20:44:35 +00:00
} else {
return;
}
} while (j2 != 0);
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onCompleted() {
2021-12-17 22:03:14 +00:00
if (!isUnsubscribed() && !this.o) {
this.o = true;
2021-06-27 20:44:35 +00:00
b();
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onError(Throwable th) {
2021-12-17 22:03:14 +00:00
if (isUnsubscribed() || this.o) {
2021-06-27 20:44:35 +00:00
l.b(th);
return;
}
2021-12-17 22:03:14 +00:00
this.r = th;
this.o = true;
2021-06-27 20:44:35 +00:00
b();
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onNext(T t) {
2021-12-17 22:03:14 +00:00
if (!isUnsubscribed() && !this.o) {
Queue<Object> queue = this.m;
2021-06-27 20:44:35 +00:00
if (t == null) {
2022-03-30 16:43:10 +00:00
t = (T) e.f3753b;
2021-06-27 20:44:35 +00:00
}
if (!queue.offer(t)) {
onError(new MissingBackpressureException());
} else {
b();
}
}
}
}
public z0(Scheduler scheduler, boolean z2, int i) {
2021-12-17 22:03:14 +00:00
this.j = scheduler;
this.k = z2;
this.l = i <= 0 ? i.j : i;
2021-06-27 20:44:35 +00:00
}
2021-11-08 18:25:28 +00:00
@Override // j0.k.b
2021-06-27 20:44:35 +00:00
public Object call(Object obj) {
Subscriber subscriber = (Subscriber) obj;
2021-12-17 22:03:14 +00:00
Scheduler scheduler = this.j;
2021-06-27 20:44:35 +00:00
if (scheduler instanceof m) {
return subscriber;
}
2021-12-17 22:03:14 +00:00
a aVar = new a(scheduler, subscriber, this.k, this.l);
Subscriber<? super T> subscriber2 = aVar.j;
2021-06-27 20:44:35 +00:00
subscriber2.setProducer(new y0(aVar));
2021-12-17 22:03:14 +00:00
subscriber2.add(aVar.k);
2021-06-27 20:44:35 +00:00
subscriber2.add(aVar);
return aVar;
}
}