discord-jadx/app/src/main/java/c/f/j/p/h1.java

104 lines
2.7 KiB
Java

package c.f.j.p;
import android.util.Pair;
import java.util.Objects;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
/* compiled from: ThrottlingProducer */
public class h1<T> implements v0<T> {
public final v0<T> a;
public int b = 0;
/* renamed from: c reason: collision with root package name */
public final ConcurrentLinkedQueue<Pair<l<T>, w0>> f472c = new ConcurrentLinkedQueue<>();
public final Executor d;
/* compiled from: ThrottlingProducer */
public class b extends p<T, T> {
/* compiled from: ThrottlingProducer */
public class a implements Runnable {
public final /* synthetic */ Pair i;
public a(Pair pair) {
this.i = pair;
}
@Override // java.lang.Runnable
public void run() {
h1 h1Var = h1.this;
Pair pair = this.i;
w0 w0Var = (w0) pair.second;
Objects.requireNonNull(h1Var);
w0Var.o().j(w0Var, "ThrottlingProducer", null);
h1Var.a.b(new b((l) pair.first, null), w0Var);
}
}
public b(l lVar, a aVar) {
super(lVar);
}
@Override // c.f.j.p.p, c.f.j.p.b
public void g() {
this.b.d();
n();
}
@Override // c.f.j.p.p, c.f.j.p.b
public void h(Throwable th) {
this.b.c(th);
n();
}
@Override // c.f.j.p.b
public void i(T t, int i) {
this.b.b(t, i);
if (b.e(i)) {
n();
}
}
public final void n() {
Pair<l<T>, w0> poll;
synchronized (h1.this) {
poll = h1.this.f472c.poll();
if (poll == null) {
h1 h1Var = h1.this;
h1Var.b--;
}
}
if (poll != null) {
h1.this.d.execute(new a(poll));
}
}
}
public h1(int i, Executor executor, v0<T> v0Var) {
Objects.requireNonNull(executor);
this.d = executor;
Objects.requireNonNull(v0Var);
this.a = v0Var;
}
@Override // c.f.j.p.v0
public void b(l<T> lVar, w0 w0Var) {
boolean z2;
w0Var.o().e(w0Var, "ThrottlingProducer");
synchronized (this) {
int i = this.b;
z2 = true;
if (i >= 5) {
this.f472c.add(Pair.create(lVar, w0Var));
} else {
this.b = i + 1;
z2 = false;
}
}
if (!z2) {
w0Var.o().j(w0Var, "ThrottlingProducer", null);
this.a.b(new b(lVar, null), w0Var);
}
}
}