package o; import java.util.concurrent.atomic.AtomicInteger; /* renamed from: o.fWR, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C13289fWR extends fUX { private long d; public C13289fWR(AbstractC13163fSk abstractC13163fSk, long j) { super(abstractC13163fSk); this.d = j; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { C13197fTk c13197fTk = new C13197fTk(); interfaceC13174fSv.onSubscribe(c13197fTk); long j = this.d; new RVV(interfaceC13174fSv, j != Long.MAX_VALUE ? j - 1 : Long.MAX_VALUE, c13197fTk, this.c).d(); } /* renamed from: o.fWR$RVV */ /* loaded from: classes6.dex */ static final class RVV extends AtomicInteger implements InterfaceC13174fSv { private InterfaceC13169fSq a; private long b; private InterfaceC13174fSv c; private C13197fTk d; RVV(InterfaceC13174fSv interfaceC13174fSv, long j, C13197fTk c13197fTk, InterfaceC13169fSq interfaceC13169fSq) { this.c = interfaceC13174fSv; this.d = c13197fTk; this.a = interfaceC13169fSq; this.b = j; } @Override // o.InterfaceC13174fSv public final void onNext(T t) { this.c.onNext(t); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { this.c.onError(th); } @Override // o.InterfaceC13174fSv public final void onComplete() { long j = this.b; if (j != Long.MAX_VALUE) { this.b = j - 1; } if (j != 0) { d(); } else { this.c.onComplete(); } } final void d() { if (getAndIncrement() == 0) { int i = 1; while (!this.d.isDisposed()) { this.a.subscribe(this); i = addAndGet(-i); if (i == 0) { return; } } } } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { EnumC13192fTf.c(this.d, fsj); } } }