package com.google.firebase.concurrent;

/* JADX INFO: loaded from: classes2.dex */
public final class a implements Runnable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f24054a = 0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Runnable f24055b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ b f24056c;

    public a(b bVar, Runnable runnable) {
        this.f24056c = bVar;
        this.f24055b = runnable;
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x0046, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x004c, code lost:
    
        r1 = r1 | java.lang.Thread.interrupted();
        r2 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:25:0x004e, code lost:
    
        r9.f24055b.run();
     */
    /* JADX WARN: Code restructure failed: missing block: B:30:0x0058, code lost:
    
        r0 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:32:0x005a, code lost:
    
        r3 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:33:0x005b, code lost:
    
        com.google.firebase.concurrent.b.f24057f.log(java.util.logging.Level.SEVERE, "Exception while executing runnable " + r9.f24055b, (java.lang.Throwable) r3);
     */
    /* JADX WARN: Code restructure failed: missing block: B:35:0x0076, code lost:
    
        r9.f24055b = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:36:0x0078, code lost:
    
        throw r0;
     */
    /* JADX WARN: Code restructure failed: missing block: B:51:?, code lost:
    
        return;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a() {
        boolean z10 = false;
        boolean zInterrupted = false;
        while (true) {
            try {
                synchronized (this.f24056c.f24059b) {
                    if (!z10) {
                        b bVar = this.f24056c;
                        SequentialExecutor$WorkerRunningState sequentialExecutor$WorkerRunningState = bVar.f24060c;
                        SequentialExecutor$WorkerRunningState sequentialExecutor$WorkerRunningState2 = SequentialExecutor$WorkerRunningState.f24049d;
                        if (sequentialExecutor$WorkerRunningState != sequentialExecutor$WorkerRunningState2) {
                            bVar.f24061d++;
                            bVar.f24060c = sequentialExecutor$WorkerRunningState2;
                            z10 = true;
                        }
                    }
                    Runnable runnable = (Runnable) this.f24056c.f24059b.poll();
                    this.f24055b = runnable;
                    if (runnable == null) {
                        this.f24056c.f24060c = SequentialExecutor$WorkerRunningState.f24046a;
                    }
                }
                if (zInterrupted) {
                    Thread.currentThread().interrupt();
                    return;
                }
                return;
            } finally {
                if (zInterrupted) {
                    Thread.currentThread().interrupt();
                }
            }
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        switch (this.f24054a) {
            case 0:
                try {
                    a();
                    return;
                } catch (Error e10) {
                    synchronized (this.f24056c.f24059b) {
                        this.f24056c.f24060c = SequentialExecutor$WorkerRunningState.f24046a;
                        throw e10;
                    }
                }
            default:
                this.f24055b.run();
                return;
        }
    }

    public final String toString() {
        switch (this.f24054a) {
            case 0:
                Runnable runnable = this.f24055b;
                if (runnable != null) {
                    return "SequentialExecutorWorker{running=" + runnable + "}";
                }
                return "SequentialExecutorWorker{state=" + this.f24056c.f24060c + "}";
            default:
                return this.f24055b.toString();
        }
    }

    public a(b bVar) {
        this.f24056c = bVar;
    }

    public /* synthetic */ a(b bVar, int i10) {
        this(bVar);
    }
}
