package o; import java.util.concurrent.CountDownLatch; /* loaded from: classes6.dex */ public final class fTM extends CountDownLatch implements InterfaceC13176fSx, InterfaceC13154fSb, InterfaceC13161fSi { private volatile boolean a; private Throwable b; private T c; private fSJ d; public fTM() { super(1); } @Override // o.InterfaceC13176fSx public final void onSubscribe(fSJ fsj) { this.d = fsj; if (this.a) { fsj.dispose(); } } @Override // o.InterfaceC13176fSx public final void e(T t) { this.c = t; countDown(); } @Override // o.InterfaceC13176fSx public final void onError(Throwable th) { this.b = th; countDown(); } @Override // o.InterfaceC13154fSb public final void onComplete() { countDown(); } public final T d() { if (getCount() != 0) { try { await(); } catch (InterruptedException e) { this.a = true; fSJ fsj = this.d; if (fsj != null) { fsj.dispose(); } throw fYR.c(e); } } Throwable th = this.b; if (th == null) { return this.c; } throw fYR.c(th); } }