package c.a.q.d;

import c.a.j;
import java.util.concurrent.CountDownLatch;

/* JADX INFO: compiled from: BlockingMultiObserver.java */
/* JADX INFO: loaded from: classes.dex */
public final class b<T> extends CountDownLatch implements j<T>, c.a.a, c.a.c<T> {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    T f1746c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    Throwable f1747d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    c.a.n.b f1748e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    volatile boolean f1749f;

    public b() {
        super(1);
    }

    @Override // c.a.j, c.a.a, c.a.c
    public void a(c.a.n.b bVar) {
        this.f1748e = bVar;
        if (this.f1749f) {
            bVar.dispose();
        }
    }

    @Override // c.a.j, c.a.a, c.a.c
    public void b(Throwable th) {
        this.f1747d = th;
        countDown();
    }

    @Override // c.a.a, c.a.c
    public void c() {
        countDown();
    }

    @Override // c.a.j
    public void d(T t) {
        this.f1746c = t;
        countDown();
    }

    public T e() {
        if (getCount() != 0) {
            try {
                c.a.q.h.a.a();
                await();
            } catch (InterruptedException e2) {
                f();
                throw c.a.q.h.b.a(e2);
            }
        }
        Throwable th = this.f1747d;
        if (th == null) {
            return this.f1746c;
        }
        throw c.a.q.h.b.a(th);
    }

    void f() {
        this.f1749f = true;
        c.a.n.b bVar = this.f1748e;
        if (bVar != null) {
            bVar.dispose();
        }
    }
}
