package o;

import java.util.concurrent.ExecutionException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Tn0 implements ST, LT, GT {
    public final Object l = new Object();
    public final int m;
    public final Hw0 n;

    /* renamed from: o, reason: collision with root package name */
    public int f347o;
    public int p;
    public int q;
    public Exception r;
    public boolean s;

    public Tn0(int i, Hw0 hw0) {
        this.m = i;
        this.n = hw0;
    }

    public final void a() {
        int i = this.f347o + this.p + this.q;
        int i2 = this.m;
        if (i == i2) {
            Exception exc = this.r;
            Hw0 hw0 = this.n;
            if (exc == null) {
                if (this.s) {
                    hw0.n();
                    return;
                } else {
                    hw0.m(null);
                    return;
                }
            }
            hw0.l(new ExecutionException(this.p + " out of " + i2 + " underlying tasks failed", this.r));
        }
    }

    @Override // o.GT
    public final void b() {
        synchronized (this.l) {
            this.q++;
            this.s = true;
            a();
        }
    }

    @Override // o.LT
    public final void d(Exception exc) {
        synchronized (this.l) {
            this.p++;
            this.r = exc;
            a();
        }
    }

    @Override // o.ST
    public final void e(Object obj) {
        synchronized (this.l) {
            this.f347o++;
            a();
        }
    }
}
