package defpackage;

import java.util.ArrayDeque;
import java.util.concurrent.Executor;

/* renamed from: ˉʽᵹ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class ExecutorC1145 implements Executor {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final Executor f4900;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final Object f4901;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final /* synthetic */ int f4902;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public Runnable f4903;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final ArrayDeque f4904;

    public ExecutorC1145(Executor executor, int i) {
        this.f4902 = i;
        switch (i) {
            case 1:
                this.f4900 = executor;
                this.f4904 = new ArrayDeque();
                this.f4901 = new Object();
                break;
            default:
                this.f4900 = executor;
                this.f4904 = new ArrayDeque();
                this.f4901 = new Object();
                break;
        }
    }

    public ExecutorC1145(ExecutorC3609 executorC3609) {
        this.f4902 = 2;
        this.f4901 = new Object();
        this.f4904 = new ArrayDeque();
        this.f4900 = executorC3609;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    private final void m3594(Runnable runnable) {
        synchronized (this.f4901) {
            try {
                this.f4904.add(new ᵧˀ(this, 28, runnable));
                if (this.f4903 == null) {
                    m3597();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    private final void m3595(Runnable runnable) {
        synchronized (this.f4901) {
            this.f4904.offer(new RunnableC5417(runnable, 20, this));
            if (this.f4903 == null) {
                m3597();
            }
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    private final void m3596() {
        synchronized (this.f4901) {
            Object objPoll = this.f4904.poll();
            Runnable runnable = (Runnable) objPoll;
            this.f4903 = runnable;
            if (objPoll != null) {
                this.f4900.execute(runnable);
            }
        }
    }

    @Override // java.util.concurrent.Executor
    public final void execute(Runnable runnable) {
        switch (this.f4902) {
            case 0:
                m3594(runnable);
                return;
            case 1:
                m3595(runnable);
                return;
            default:
                synchronized (this.f4901) {
                    try {
                        this.f4904.add(new RunnableC0421(this, 2, runnable));
                        if (this.f4903 == null) {
                            m3597();
                        }
                    } catch (Throwable th) {
                        throw th;
                    }
                }
                return;
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m3597() {
        switch (this.f4902) {
            case 0:
                Runnable runnable = (Runnable) this.f4904.poll();
                this.f4903 = runnable;
                if (runnable != null) {
                    this.f4900.execute(runnable);
                    return;
                }
                return;
            case 1:
                m3596();
                return;
            default:
                synchronized (this.f4901) {
                    try {
                        Runnable runnable2 = (Runnable) this.f4904.poll();
                        this.f4903 = runnable2;
                        if (runnable2 != null) {
                            ((ExecutorC3609) this.f4900).execute(runnable2);
                        }
                    } catch (Throwable th) {
                        throw th;
                    }
                }
                return;
        }
    }
}
