198 lines
5.9 KiB
Java
198 lines
5.9 KiB
Java
package j0.l.e;
|
|
|
|
import j0.l.a.a1;
|
|
import j0.l.a.e;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import rx.Producer;
|
|
/* compiled from: BackpressureDrainManager */
|
|
public final class c extends AtomicLong implements Producer {
|
|
private static final long serialVersionUID = 2826241102729529449L;
|
|
public final a actual;
|
|
public boolean emitting;
|
|
public Throwable exception;
|
|
public volatile boolean terminated;
|
|
|
|
/* compiled from: BackpressureDrainManager */
|
|
public interface a {
|
|
}
|
|
|
|
public c(a aVar) {
|
|
this.actual = aVar;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:19:?, code lost:
|
|
r1 = r14.exception;
|
|
r5 = (j0.l.a.a1.a) r5;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:20:0x002e, code lost:
|
|
if (r1 == null) goto L_0x0036;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:21:0x0030, code lost:
|
|
r5.k.onError(r1);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:22:0x0036, code lost:
|
|
r5.k.onCompleted();
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:65:0x00a2, code lost:
|
|
r0 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:66:0x00a3, code lost:
|
|
r1 = r0;
|
|
r0 = r1;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:97:?, code lost:
|
|
return;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:98:?, code lost:
|
|
return;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:75:0x00c2 */
|
|
public void a() {
|
|
boolean z2;
|
|
boolean z3;
|
|
c cVar;
|
|
Throwable th;
|
|
a aVar;
|
|
boolean z4;
|
|
Throwable th2;
|
|
boolean z5;
|
|
synchronized (this) {
|
|
if (!this.emitting) {
|
|
z2 = true;
|
|
this.emitting = true;
|
|
z3 = this.terminated;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
long j = get();
|
|
try {
|
|
aVar = this.actual;
|
|
this.emitting = false;
|
|
return;
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
cVar = this;
|
|
z2 = false;
|
|
if (!z2) {
|
|
synchronized (cVar) {
|
|
cVar.emitting = false;
|
|
}
|
|
}
|
|
throw th;
|
|
}
|
|
loop0:
|
|
while (true) {
|
|
int i = 0;
|
|
while (true) {
|
|
int i2 = (j > 0 ? 1 : (j == 0 ? 0 : -1));
|
|
if (i2 <= 0 && !z3) {
|
|
break;
|
|
}
|
|
if (z3) {
|
|
if (((a1.a) aVar).i.peek() != null) {
|
|
if (i2 == 0) {
|
|
break;
|
|
}
|
|
} else {
|
|
try {
|
|
break loop0;
|
|
} catch (Throwable th4) {
|
|
th = th4;
|
|
cVar = this;
|
|
if (!z2) {
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
a1.a aVar2 = (a1.a) aVar;
|
|
Object poll = aVar2.i.poll();
|
|
AtomicLong atomicLong = aVar2.j;
|
|
if (!(atomicLong == null || poll == null)) {
|
|
atomicLong.incrementAndGet();
|
|
}
|
|
if (poll == null) {
|
|
break;
|
|
} else if (!e.a(((a1.a) aVar).k, poll)) {
|
|
j--;
|
|
i++;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
synchronized (this) {
|
|
try {
|
|
z3 = this.terminated;
|
|
z5 = ((a1.a) aVar).i.peek() != null;
|
|
} catch (Throwable th5) {
|
|
th2 = th5;
|
|
z4 = false;
|
|
cVar = this;
|
|
while (true) {
|
|
try {
|
|
break;
|
|
} catch (Throwable th6) {
|
|
th2 = th6;
|
|
}
|
|
}
|
|
throw th2;
|
|
}
|
|
if (get() != Long.MAX_VALUE) {
|
|
long addAndGet = addAndGet((long) (-i));
|
|
if ((addAndGet == 0 || !z5) && (!z3 || z5)) {
|
|
break;
|
|
}
|
|
j = addAndGet;
|
|
} else if (z5 || z3) {
|
|
j = Long.MAX_VALUE;
|
|
} else {
|
|
try {
|
|
this.emitting = false;
|
|
return;
|
|
} catch (Throwable th7) {
|
|
cVar = this;
|
|
th2 = th7;
|
|
z4 = true;
|
|
while (true) {
|
|
break;
|
|
}
|
|
throw th2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // rx.Producer
|
|
public void j(long j) {
|
|
boolean z2;
|
|
if (j != 0) {
|
|
while (true) {
|
|
long j2 = get();
|
|
boolean z3 = true;
|
|
z2 = j2 == 0;
|
|
long j3 = Long.MAX_VALUE;
|
|
if (j2 == Long.MAX_VALUE) {
|
|
break;
|
|
}
|
|
if (j == Long.MAX_VALUE) {
|
|
j3 = j;
|
|
} else {
|
|
if (j2 <= Long.MAX_VALUE - j) {
|
|
j3 = j2 + j;
|
|
}
|
|
z3 = z2;
|
|
}
|
|
if (compareAndSet(j2, j3)) {
|
|
z2 = z3;
|
|
break;
|
|
}
|
|
}
|
|
if (z2) {
|
|
a();
|
|
}
|
|
}
|
|
}
|
|
}
|