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

96 lines
2.4 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
2021-11-08 18:25:28 +00:00
import j0.o.l;
2021-06-27 20:44:35 +00:00
import java.util.concurrent.atomic.AtomicLong;
import rx.Producer;
import rx.Subscriber;
2022-03-02 20:59:20 +00:00
/* compiled from: OperatorTake.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public class b2 extends Subscriber<T> {
2021-12-17 22:03:14 +00:00
public int j;
public boolean k;
public final /* synthetic */ Subscriber l;
public final /* synthetic */ c2 m;
2021-06-27 20:44:35 +00:00
2022-03-02 20:59:20 +00:00
/* compiled from: OperatorTake.java */
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public class a implements Producer {
2021-12-17 22:03:14 +00:00
public final AtomicLong j = new AtomicLong(0);
public final /* synthetic */ Producer k;
2021-06-27 20:44:35 +00:00
public a(Producer producer) {
2021-12-17 22:03:14 +00:00
this.k = producer;
2021-06-27 20:44:35 +00:00
}
@Override // rx.Producer
public void j(long j) {
long j2;
long min;
2021-12-17 22:03:14 +00:00
if (j > 0 && !b2.this.k) {
2021-06-27 20:44:35 +00:00
do {
2021-12-17 22:03:14 +00:00
j2 = this.j.get();
2022-03-02 20:59:20 +00:00
min = Math.min(j, b2.this.m.j - j2);
2021-06-27 20:44:35 +00:00
if (min == 0) {
return;
}
2021-12-17 22:03:14 +00:00
} while (!this.j.compareAndSet(j2, j2 + min));
this.k.j(min);
2021-06-27 20:44:35 +00:00
}
}
}
public b2(c2 c2Var, Subscriber subscriber) {
2021-12-17 22:03:14 +00:00
this.m = c2Var;
this.l = subscriber;
2021-06-27 20:44:35 +00:00
}
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 (!this.k) {
this.k = true;
this.l.onCompleted();
2021-06-27 20:44:35 +00:00
}
}
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 (!this.k) {
this.k = true;
2021-06-27 20:44:35 +00:00
try {
2021-12-17 22:03:14 +00:00
this.l.onError(th);
2021-06-27 20:44:35 +00:00
} finally {
unsubscribe();
}
} else {
l.b(th);
}
}
2021-11-08 18:25:28 +00:00
@Override // j0.g
2021-06-27 20:44:35 +00:00
public void onNext(T t) {
if (!isUnsubscribed()) {
2021-12-17 22:03:14 +00:00
int i = this.j;
2021-06-27 20:44:35 +00:00
int i2 = i + 1;
2021-12-17 22:03:14 +00:00
this.j = i2;
int i3 = this.m.j;
2021-06-27 20:44:35 +00:00
if (i < i3) {
boolean z2 = i2 == i3;
2021-12-17 22:03:14 +00:00
this.l.onNext(t);
if (z2 && !this.k) {
this.k = true;
2021-06-27 20:44:35 +00:00
try {
2021-12-17 22:03:14 +00:00
this.l.onCompleted();
2021-06-27 20:44:35 +00:00
} finally {
unsubscribe();
}
}
}
}
}
@Override // rx.Subscriber
public void setProducer(Producer producer) {
2021-12-17 22:03:14 +00:00
this.l.setProducer(new a(producer));
2021-06-27 20:44:35 +00:00
}
}