what-the-bank/sources/o/C13221fUU.java

94 lines
3.0 KiB
Java

package o;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicReference;
/* renamed from: o.fUU, reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public final class C13221fUU<T> implements Iterable<T> {
private InterfaceC13169fSq<T> e;
public C13221fUU(InterfaceC13169fSq<T> interfaceC13169fSq) {
this.e = interfaceC13169fSq;
}
@Override // java.lang.Iterable
public final Iterator<T> iterator() {
Sts sts = new Sts();
AbstractC13163fSk.wrap(this.e).materialize().subscribe(sts);
return sts;
}
/* renamed from: o.fUU$Sts */
/* loaded from: classes6.dex */
static final class Sts<T> extends AbstractC13403fZf<C13166fSn<T>> implements Iterator<T> {
private C13166fSn<T> d;
private Semaphore a = new Semaphore(0);
private AtomicReference<C13166fSn<T>> e = new AtomicReference<>();
@Override // o.InterfaceC13174fSv
public final void onComplete() {
}
Sts() {
}
@Override // o.InterfaceC13174fSv
public final /* synthetic */ void onNext(Object obj) {
if (this.e.getAndSet((C13166fSn) obj) == null) {
this.a.release();
}
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
C13418fZu.c(th);
}
@Override // java.util.Iterator
public final boolean hasNext() {
C13166fSn<T> c13166fSn = this.d;
if (c13166fSn != null && fYX.b(c13166fSn.a)) {
Object obj = this.d.a;
throw fYR.c(fYX.b(obj) ? fYX.a(obj) : null);
}
if (this.d == null) {
try {
this.a.acquire();
C13166fSn<T> andSet = this.e.getAndSet(null);
this.d = andSet;
if (fYX.b(andSet.a)) {
Object obj2 = andSet.a;
throw fYR.c(fYX.b(obj2) ? fYX.a(obj2) : null);
}
} catch (InterruptedException e) {
dispose();
this.d = C13166fSn.a((Throwable) e);
throw fYR.c(e);
}
}
Object obj3 = this.d.a;
return (obj3 == null || fYX.b(obj3)) ? false : true;
}
@Override // java.util.Iterator
public final T next() {
if (hasNext()) {
C13166fSn<T> c13166fSn = this.d;
Object obj = c13166fSn.a;
T t = (obj == null || fYX.b(obj)) ? null : (T) c13166fSn.a;
this.d = null;
return t;
}
throw new NoSuchElementException();
}
@Override // java.util.Iterator
public final void remove() {
throw new UnsupportedOperationException("Read-only iterator.");
}
}
}