package g3;

import java.util.concurrent.ExecutionException;

/* JADX INFO: loaded from: classes.dex */
public final class k implements e, d, InterfaceC0984b {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final Object f12927q = new Object();

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final int f12928r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final o f12929s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f12930t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f12931u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public int f12932v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public Exception f12933w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public boolean f12934x;

    public k(int i, o oVar) {
        this.f12928r = i;
        this.f12929s = oVar;
    }

    public final void a() {
        int i = this.f12930t + this.f12931u + this.f12932v;
        int i5 = this.f12928r;
        if (i == i5) {
            Exception exc = this.f12933w;
            o oVar = this.f12929s;
            if (exc == null) {
                if (this.f12934x) {
                    oVar.m();
                    return;
                } else {
                    oVar.l(null);
                    return;
                }
            }
            oVar.k(new ExecutionException(this.f12931u + " out of " + i5 + " underlying tasks failed", this.f12933w));
        }
    }

    @Override // g3.InterfaceC0984b
    public final void b() {
        synchronized (this.f12927q) {
            this.f12932v++;
            this.f12934x = true;
            a();
        }
    }

    @Override // g3.e
    public final void d(Object obj) {
        synchronized (this.f12927q) {
            this.f12930t++;
            a();
        }
    }

    @Override // g3.d
    public final void l(Exception exc) {
        synchronized (this.f12927q) {
            this.f12931u++;
            this.f12933w = exc;
            a();
        }
    }
}
