discord-jadx/app/src/main/java/s/a/w1/c.java
2021-06-27 22:44:35 +02:00

164 lines
5.1 KiB
Java

package s.a.w1;
import c.q.a.k.a;
import d0.b;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.Objects;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlinx.coroutines.channels.ClosedSendChannelException;
import kotlinx.coroutines.internal.UndeliveredElementException;
import s.a.a.h;
import s.a.a.j;
import s.a.a.p;
import s.a.a.r;
/* compiled from: AbstractChannel.kt */
public abstract class c<E> implements l<E> {
public final h a = new h();
public final Function1<E, Unit> b;
public volatile Object onCloseHandler = null;
/* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: kotlin.jvm.functions.Function1<? super E, kotlin.Unit> */
/* JADX WARN: Multi-variable type inference failed */
public c(Function1<? super E, Unit> function1) {
this.b = function1;
}
public abstract String a();
public final f<?> b() {
j k = this.a.k();
if (!(k instanceof f)) {
k = null;
}
f<?> fVar = (f) k;
if (fVar == null) {
return null;
}
c(fVar);
return fVar;
}
/* JADX DEBUG: Multi-variable search result rejected for r3v5, resolved type: java.util.ArrayList */
/* JADX DEBUG: Multi-variable search result rejected for r3v6, resolved type: java.util.ArrayList */
/* JADX WARN: Multi-variable type inference failed */
public final void c(f<?> fVar) {
h hVar = null;
while (true) {
j k = fVar.k();
if (!(k instanceof h)) {
k = null;
}
h hVar2 = (h) k;
if (hVar2 == null) {
break;
} else if (!hVar2.n()) {
Object i = hVar2.i();
Objects.requireNonNull(i, "null cannot be cast to non-null type kotlinx.coroutines.internal.Removed");
((p) i).a.f(null);
} else if (hVar == null) {
hVar = hVar2;
} else if (hVar instanceof ArrayList) {
((ArrayList) hVar).add(hVar2);
} else {
ArrayList arrayList = new ArrayList(4);
arrayList.add(hVar);
arrayList.add(hVar2);
hVar = arrayList;
}
}
if (hVar != null) {
if (!(hVar instanceof ArrayList)) {
hVar.q(fVar);
return;
}
ArrayList arrayList2 = (ArrayList) hVar;
for (int size = arrayList2.size() - 1; size >= 0; size--) {
((h) arrayList2.get(size)).q(fVar);
}
}
}
public final Throwable d(E e, f<?> fVar) {
UndeliveredElementException h;
c(fVar);
Function1<E, Unit> function1 = this.b;
if (function1 == null || (h = a.h(function1, e, null)) == null) {
return new ClosedSendChannelException("Channel was closed");
}
b.addSuppressed(h, new ClosedSendChannelException("Channel was closed"));
throw h;
}
public abstract Object e(E e);
@Override // s.a.w1.l
public final boolean offer(E e) {
Object e2 = e(e);
if (e2 == b.b) {
return true;
}
if (e2 == b.f2871c) {
f<?> b = b();
if (b == null) {
return false;
}
Throwable d = d(e, b);
String str = r.a;
throw d;
} else if (e2 instanceof f) {
Throwable d2 = d(e, (f) e2);
String str2 = r.a;
throw d2;
} else {
throw new IllegalStateException(c.d.b.a.a.t("offerInternal returned ", e2).toString());
}
}
public String toString() {
String str;
String str2;
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append('@');
sb.append(a.t(this));
sb.append('{');
j j = this.a.j();
if (j == this.a) {
str = "EmptyQueue";
} else {
if (j instanceof f) {
str2 = j.toString();
} else if (j instanceof h) {
str2 = "ReceiveQueued";
} else if (j instanceof k) {
str2 = "SendQueued";
} else {
str2 = "UNEXPECTED:" + j;
}
j k = this.a.k();
if (k != j) {
StringBuilder P = c.d.b.a.a.P(str2, ",queueSize=");
h hVar = this.a;
Object i = hVar.i();
Objects.requireNonNull(i, "null cannot be cast to non-null type kotlinx.coroutines.internal.Node /* = kotlinx.coroutines.internal.LockFreeLinkedListNode */");
int i2 = 0;
for (j jVar = (j) i; !m.areEqual(jVar, hVar); jVar = jVar.j()) {
i2++;
}
P.append(i2);
str = P.toString();
if (k instanceof f) {
str = str + ",closedForSend=" + k;
}
} else {
str = str2;
}
}
sb.append(str);
sb.append('}');
sb.append(a());
return sb.toString();
}
}