145 lines
4.1 KiB
Java
145 lines
4.1 KiB
Java
package o;
|
|
|
|
import com.google.android.gms.analytics.ecommerce.ProductAction;
|
|
import java.util.Iterator;
|
|
import java.util.NoSuchElementException;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.locks.Condition;
|
|
import java.util.concurrent.locks.Lock;
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class fUW<T> implements Iterable<T> {
|
|
private InterfaceC13169fSq<? extends T> b;
|
|
private int d;
|
|
|
|
public fUW(InterfaceC13169fSq<? extends T> interfaceC13169fSq, int i) {
|
|
this.b = interfaceC13169fSq;
|
|
this.d = i;
|
|
}
|
|
|
|
@Override // java.lang.Iterable
|
|
public final Iterator<T> iterator() {
|
|
Sts sts = new Sts(this.d);
|
|
this.b.subscribe(sts);
|
|
return sts;
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
static final class Sts<T> extends AtomicReference<fSJ> implements InterfaceC13174fSv<T>, Iterator<T>, fSJ {
|
|
private Condition a;
|
|
private C13416fZs<T> b;
|
|
private Lock c;
|
|
private volatile Throwable d;
|
|
private volatile boolean e;
|
|
|
|
Sts(int i) {
|
|
this.b = new C13416fZs<>(i);
|
|
ReentrantLock reentrantLock = new ReentrantLock();
|
|
this.c = reentrantLock;
|
|
this.a = reentrantLock.newCondition();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public final boolean hasNext() {
|
|
while (!isDisposed()) {
|
|
boolean z = this.e;
|
|
C13416fZs<T> c13416fZs = this.b;
|
|
boolean z2 = c13416fZs.b.get() == c13416fZs.e.get();
|
|
if (z) {
|
|
Throwable th = this.d;
|
|
if (th != null) {
|
|
throw fYR.c(th);
|
|
}
|
|
if (z2) {
|
|
return false;
|
|
}
|
|
}
|
|
if (!z2) {
|
|
return true;
|
|
}
|
|
try {
|
|
this.c.lock();
|
|
while (!this.e) {
|
|
try {
|
|
C13416fZs<T> c13416fZs2 = this.b;
|
|
if (c13416fZs2.b.get() == c13416fZs2.e.get() && !isDisposed()) {
|
|
this.a.await();
|
|
}
|
|
this.c.unlock();
|
|
} finally {
|
|
}
|
|
}
|
|
this.c.unlock();
|
|
} catch (InterruptedException e) {
|
|
EnumC13192fTf.e(this);
|
|
c();
|
|
throw fYR.c(e);
|
|
}
|
|
}
|
|
Throwable th2 = this.d;
|
|
if (th2 == null) {
|
|
return false;
|
|
}
|
|
throw fYR.c(th2);
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public final T next() {
|
|
if (hasNext()) {
|
|
return this.b.b();
|
|
}
|
|
throw new NoSuchElementException();
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
EnumC13192fTf.a(this, fsj);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
this.b.b(t);
|
|
c();
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
this.d = th;
|
|
this.e = true;
|
|
c();
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
this.e = true;
|
|
c();
|
|
}
|
|
|
|
private void c() {
|
|
this.c.lock();
|
|
try {
|
|
this.a.signalAll();
|
|
} finally {
|
|
this.c.unlock();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public final void remove() {
|
|
throw new UnsupportedOperationException(ProductAction.ACTION_REMOVE);
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
EnumC13192fTf.e(this);
|
|
c();
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return EnumC13192fTf.c(get());
|
|
}
|
|
}
|
|
}
|