package ʬ;

import bolts.ExecutorException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;

/* renamed from: ʬ.ⁱ  reason: contains not printable characters */
/* compiled from: Task */
public class C0595<TResult> {

    /* renamed from: ᕣ  reason: contains not printable characters */
    public static C0595<Boolean> f3545 = new C0595<>((Boolean) true);

    /* renamed from: ᨨ  reason: contains not printable characters */
    public static final Executor f3546;

    /* renamed from: 㑃  reason: contains not printable characters */
    public static C0595<Boolean> f3547 = new C0595<>((Boolean) false);

    /* renamed from: 㳳  reason: contains not printable characters */
    public static C0595<?> f3548 = new C0595<>((Object) null);

    /* renamed from: 䁗  reason: contains not printable characters */
    public static C0595<?> f3549 = new C0595<>(true);

    /* renamed from: ʬ  reason: contains not printable characters */
    public boolean f3550;

    /* renamed from: ඓ  reason: contains not printable characters */
    public Exception f3551;

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean f3552;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public C0602 f3553;

    /* renamed from: K  reason: contains not printable characters */
    public final Object f3554 = new Object();

    /* renamed from: 㴹  reason: contains not printable characters */
    public boolean f3555;

    /* renamed from: 㸾  reason: contains not printable characters */
    public TResult f3556;

    /* renamed from: 㿎  reason: contains not printable characters */
    public List<AbstractC0605<TResult, Void>> f3557 = new ArrayList();

    /* renamed from: ʬ.ⁱ$ʬ  reason: contains not printable characters */
    /* compiled from: Task */
    public class C0596 extends C0591<TResult> {
        public C0596(C0595 r1) {
        }
    }

    /* renamed from: ʬ.ⁱ$ῲ  reason: contains not printable characters */
    /* compiled from: Task */
    public class C0597 implements AbstractC0605<TResult, Void> {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ Executor f3558;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ AbstractC0605 f3559;

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ C0591 f3560;

        public C0597(C0595 r1, C0591 r2, AbstractC0605 r3, Executor executor) {
            this.f3560 = r2;
            this.f3559 = r3;
            this.f3558 = executor;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        @Override // ʬ.AbstractC0605
        public Void then(C0595 r4) throws Exception {
            C0595.m2026(this.f3560, this.f3559, r4, this.f3558);
            return null;
        }
    }

    /* renamed from: ʬ.ⁱ$K  reason: contains not printable characters */
    /* compiled from: Task */
    public class C0598 implements AbstractC0605<TResult, Void> {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ Executor f3561;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ AbstractC0605 f3562;

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ C0591 f3563;

        public C0598(C0595 r1, C0591 r2, AbstractC0605 r3, Executor executor) {
            this.f3563 = r2;
            this.f3562 = r3;
            this.f3561 = executor;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        @Override // ʬ.AbstractC0605
        public Void then(C0595 r4) throws Exception {
            C0595.m2025(this.f3563, this.f3562, r4, this.f3561);
            return null;
        }
    }

    static {
        C0606 r0 = C0606.f3575;
        ExecutorService executorService = r0.f3577;
        f3546 = r0.f3576;
        Executor executor = C0599.f3566.f3568;
    }

    public C0595() {
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public static <TResult> C0595<TResult> m2027() {
        return (C0595<TResult>) f3549;
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public boolean m2028() {
        boolean z;
        synchronized (this.f3554) {
            z = this.f3550;
        }
        return z;
    }

    /* renamed from: ඓ  reason: contains not printable characters */
    public boolean m2029() {
        boolean z;
        synchronized (this.f3554) {
            z = m2034() != null;
        }
        return z;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public TResult m2030() {
        TResult tresult;
        synchronized (this.f3554) {
            tresult = this.f3556;
        }
        return tresult;
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public boolean m2033() {
        synchronized (this.f3554) {
            if (this.f3552) {
                return false;
            }
            this.f3552 = true;
            this.f3550 = true;
            this.f3554.notifyAll();
            m2039();
            return true;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public Exception m2034() {
        Exception exc;
        synchronized (this.f3554) {
            if (this.f3551 != null) {
                this.f3555 = true;
                if (this.f3553 != null) {
                    this.f3553.f3569 = null;
                    this.f3553 = null;
                }
            }
            exc = this.f3551;
        }
        return exc;
    }

    /* renamed from: 㴹  reason: contains not printable characters */
    public final void m2039() {
        synchronized (this.f3554) {
            for (AbstractC0605<TResult, Void> r2 : this.f3557) {
                try {
                    r2.then(this);
                } catch (RuntimeException e) {
                    throw e;
                } catch (Exception e2) {
                    throw new RuntimeException(e2);
                }
            }
            this.f3557 = null;
        }
    }

    /* renamed from: 㸾  reason: contains not printable characters */
    public boolean m2040() {
        boolean z;
        synchronized (this.f3554) {
            z = this.f3552;
        }
        return z;
    }

    public C0595(TResult tresult) {
        m2038((Object) tresult);
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static <TResult> C0595<TResult> m2024(TResult tresult) {
        if (tresult == null) {
            return (C0595<TResult>) f3548;
        }
        if (tresult instanceof Boolean) {
            return tresult.booleanValue() ? (C0595<TResult>) f3545 : (C0595<TResult>) f3547;
        }
        C0595<TResult> r0 = new C0595<>();
        if (r0.m2038((Object) tresult)) {
            return r0;
        }
        throw new IllegalStateException("Cannot set the result of a completed task.");
    }

    public C0595(boolean z) {
        if (z) {
            m2033();
        } else {
            m2038((Object) null);
        }
    }

    /* JADX DEBUG: Type inference failed for r5v2. Raw type applied. Possible types: ʬ.ⁱ<TResult>, ʬ.ⁱ<TContinuationResult> */
    /* renamed from: ῲ  reason: contains not printable characters */
    public <TContinuationResult> C0595<TContinuationResult> m2032(AbstractC0605<TResult, C0595<TContinuationResult>> r5, Executor executor, C0590 r7) {
        boolean r1;
        C0591 r72 = new C0591();
        synchronized (this.f3554) {
            r1 = m2040();
            if (!r1) {
                this.f3557.add(new C0597(this, r72, r5, executor));
            }
        }
        if (r1) {
            try {
                executor.execute(new RunnableC0603(r72, r5, this));
            } catch (Exception e) {
                r72.m2022((Exception) new ExecutorException(e));
            }
        }
        return (C0595<TResult>) r72.f3541;
    }

    /* JADX DEBUG: Type inference failed for r5v2. Raw type applied. Possible types: ʬ.ⁱ<TResult>, ʬ.ⁱ<TContinuationResult> */
    /* renamed from: K  reason: contains not printable characters */
    public <TContinuationResult> C0595<TContinuationResult> m2036(AbstractC0605<TResult, TContinuationResult> r5, Executor executor, C0590 r7) {
        boolean r1;
        C0591 r72 = new C0591();
        synchronized (this.f3554) {
            r1 = m2040();
            if (!r1) {
                this.f3557.add(new C0598(this, r72, r5, executor));
            }
        }
        if (r1) {
            try {
                executor.execute(new RunnableC0592(r72, r5, this));
            } catch (Exception e) {
                r72.m2022((Exception) new ExecutorException(e));
            }
        }
        return (C0595<TResult>) r72.f3541;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public <TContinuationResult> C0595<TContinuationResult> m2031(AbstractC0605<TResult, TContinuationResult> r3) {
        return m2032(new C0609(this, r3), f3546, null);
    }

    /* renamed from: K  reason: contains not printable characters */
    public <TContinuationResult> C0595<TContinuationResult> m2035(AbstractC0605<TResult, TContinuationResult> r3) {
        return m2036(r3, f3546, null);
    }

    /* JADX WARN: Incorrect args count in method signature: <TContinuationResult:Ljava/lang/Object;TResult:Ljava/lang/Object;>(Lʬ/ᕣ<TTContinuationResult;>;Lʬ/㴹<TTResult;Lʬ/ⁱ<TTContinuationResult;>;>;Lʬ/ⁱ<TTResult;>;Ljava/util/concurrent/Executor;Lʬ/ඓ;)V */
    /* renamed from: K  reason: contains not printable characters */
    public static void m2026(C0591 r1, AbstractC0605 r2, C0595 r3, Executor executor) {
        try {
            executor.execute(new RunnableC0603(r1, r2, r3));
        } catch (Exception e) {
            r1.m2022((Exception) new ExecutorException(e));
        }
    }

    /* JADX WARN: Incorrect args count in method signature: <TContinuationResult:Ljava/lang/Object;TResult:Ljava/lang/Object;>(Lʬ/ᕣ<TTContinuationResult;>;Lʬ/㴹<TTResult;TTContinuationResult;>;Lʬ/ⁱ<TTResult;>;Ljava/util/concurrent/Executor;Lʬ/ඓ;)V */
    /* renamed from: ῲ  reason: contains not printable characters */
    public static void m2025(C0591 r1, AbstractC0605 r2, C0595 r3, Executor executor) {
        try {
            executor.execute(new RunnableC0592(r1, r2, r3));
        } catch (Exception e) {
            r1.m2022((Exception) new ExecutorException(e));
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public boolean m2038(TResult tresult) {
        synchronized (this.f3554) {
            if (this.f3552) {
                return false;
            }
            this.f3552 = true;
            this.f3556 = tresult;
            this.f3554.notifyAll();
            m2039();
            return true;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public boolean m2037(Exception exc) {
        synchronized (this.f3554) {
            if (this.f3552) {
                return false;
            }
            this.f3552 = true;
            this.f3551 = exc;
            this.f3555 = false;
            this.f3554.notifyAll();
            m2039();
            boolean z = this.f3555;
            return true;
        }
    }
}
