package c4; import com.google.android.gms.common.internal.Preconditions; import java.util.ArrayDeque; import java.util.Deque; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; import java.util.logging.Logger; /* loaded from: classes2.dex */ final class l implements Executor { /* renamed from: f, reason: collision with root package name */ private static final Logger f3710f = Logger.getLogger(l.class.getName()); /* renamed from: a, reason: collision with root package name */ private final Executor f3711a; /* renamed from: b, reason: collision with root package name */ private final Deque f3712b = new ArrayDeque(); /* renamed from: c, reason: collision with root package name */ private c f3713c = c.IDLE; /* renamed from: d, reason: collision with root package name */ private long f3714d = 0; /* renamed from: e, reason: collision with root package name */ private final b f3715e = new b(this, null); class a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ Runnable f3716a; a(Runnable runnable) { this.f3716a = runnable; } @Override // java.lang.Runnable public void run() { this.f3716a.run(); } public String toString() { return this.f3716a.toString(); } } private final class b implements Runnable { /* renamed from: a, reason: collision with root package name */ Runnable f3718a; private b() { } /* JADX WARN: Code restructure failed: missing block: B:10:0x0052, code lost: r1 = r1 | java.lang.Thread.interrupted(); r2 = null; */ /* JADX WARN: Code restructure failed: missing block: B:12:0x0054, code lost: r8.f3718a.run(); */ /* JADX WARN: Code restructure failed: missing block: B:16:0x005e, code lost: r3 = move-exception; */ /* JADX WARN: Code restructure failed: missing block: B:17:0x005f, code lost: c4.l.f3710f.log(java.util.logging.Level.SEVERE, "Exception while executing runnable " + r8.f3718a, (java.lang.Throwable) r3); */ /* JADX WARN: Code restructure failed: missing block: B:19:0x005c, code lost: r0 = move-exception; */ /* JADX WARN: Code restructure failed: missing block: B:20:0x007c, code lost: r8.f3718a = null; */ /* JADX WARN: Code restructure failed: missing block: B:21:0x007e, code lost: throw r0; */ /* JADX WARN: Code restructure failed: missing block: B:28:0x004c, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:29:?, code lost: return; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private void a() { /* r8 = this; r0 = 0 r1 = 0 L2: c4.l r2 = c4.l.this // Catch: java.lang.Throwable -> L82 java.util.Deque r2 = c4.l.a(r2) // Catch: java.lang.Throwable -> L82 monitor-enter(r2) // Catch: java.lang.Throwable -> L82 if (r0 != 0) goto L2b c4.l r0 = c4.l.this // Catch: java.lang.Throwable -> L7f c4.l$c r0 = c4.l.b(r0) // Catch: java.lang.Throwable -> L7f c4.l$c r3 = c4.l.c.RUNNING // Catch: java.lang.Throwable -> L7f if (r0 != r3) goto L20 monitor-exit(r2) // Catch: java.lang.Throwable -> L7f if (r1 == 0) goto L1f java.lang.Thread r0 = java.lang.Thread.currentThread() r0.interrupt() L1f: return L20: c4.l r0 = c4.l.this // Catch: java.lang.Throwable -> L7f c4.l.d(r0) // Catch: java.lang.Throwable -> L7f c4.l r0 = c4.l.this // Catch: java.lang.Throwable -> L7f c4.l.c(r0, r3) // Catch: java.lang.Throwable -> L7f r0 = 1 L2b: c4.l r3 = c4.l.this // Catch: java.lang.Throwable -> L7f java.util.Deque r3 = c4.l.a(r3) // Catch: java.lang.Throwable -> L7f java.lang.Object r3 = r3.poll() // Catch: java.lang.Throwable -> L7f java.lang.Runnable r3 = (java.lang.Runnable) r3 // Catch: java.lang.Throwable -> L7f r8.f3718a = r3 // Catch: java.lang.Throwable -> L7f if (r3 != 0) goto L4d c4.l r0 = c4.l.this // Catch: java.lang.Throwable -> L7f c4.l$c r3 = c4.l.c.IDLE // Catch: java.lang.Throwable -> L7f c4.l.c(r0, r3) // Catch: java.lang.Throwable -> L7f monitor-exit(r2) // Catch: java.lang.Throwable -> L7f if (r1 == 0) goto L4c java.lang.Thread r0 = java.lang.Thread.currentThread() r0.interrupt() L4c: return L4d: monitor-exit(r2) // Catch: java.lang.Throwable -> L7f boolean r2 = java.lang.Thread.interrupted() // Catch: java.lang.Throwable -> L82 r1 = r1 | r2 r2 = 0 java.lang.Runnable r3 = r8.f3718a // Catch: java.lang.Throwable -> L5c java.lang.RuntimeException -> L5e r3.run() // Catch: java.lang.Throwable -> L5c java.lang.RuntimeException -> L5e L59: r8.f3718a = r2 // Catch: java.lang.Throwable -> L82 goto L2 L5c: r0 = move-exception goto L7c L5e: r3 = move-exception java.util.logging.Logger r4 = c4.l.e() // Catch: java.lang.Throwable -> L5c java.util.logging.Level r5 = java.util.logging.Level.SEVERE // Catch: java.lang.Throwable -> L5c java.lang.StringBuilder r6 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L5c r6.() // Catch: java.lang.Throwable -> L5c java.lang.String r7 = "Exception while executing runnable " r6.append(r7) // Catch: java.lang.Throwable -> L5c java.lang.Runnable r7 = r8.f3718a // Catch: java.lang.Throwable -> L5c r6.append(r7) // Catch: java.lang.Throwable -> L5c java.lang.String r6 = r6.toString() // Catch: java.lang.Throwable -> L5c r4.log(r5, r6, r3) // Catch: java.lang.Throwable -> L5c goto L59 L7c: r8.f3718a = r2 // Catch: java.lang.Throwable -> L82 throw r0 // Catch: java.lang.Throwable -> L82 L7f: r0 = move-exception monitor-exit(r2) // Catch: java.lang.Throwable -> L7f throw r0 // Catch: java.lang.Throwable -> L82 L82: r0 = move-exception if (r1 == 0) goto L8c java.lang.Thread r1 = java.lang.Thread.currentThread() r1.interrupt() L8c: throw r0 */ throw new UnsupportedOperationException("Method not decompiled: c4.l.b.a():void"); } @Override // java.lang.Runnable public void run() { try { a(); } catch (Error e10) { synchronized (l.this.f3712b) { l.this.f3713c = c.IDLE; throw e10; } } } public String toString() { Runnable runnable = this.f3718a; if (runnable != null) { return "SequentialExecutorWorker{running=" + runnable + "}"; } return "SequentialExecutorWorker{state=" + l.this.f3713c + "}"; } /* synthetic */ b(l lVar, a aVar) { this(); } } enum c { IDLE, QUEUING, QUEUED, RUNNING } l(Executor executor) { this.f3711a = (Executor) Preconditions.checkNotNull(executor); } static /* synthetic */ long d(l lVar) { long j10 = lVar.f3714d; lVar.f3714d = 1 + j10; return j10; } @Override // java.util.concurrent.Executor public void execute(Runnable runnable) { c cVar; Preconditions.checkNotNull(runnable); synchronized (this.f3712b) { c cVar2 = this.f3713c; if (cVar2 != c.RUNNING && cVar2 != (cVar = c.QUEUED)) { long j10 = this.f3714d; a aVar = new a(runnable); this.f3712b.add(aVar); c cVar3 = c.QUEUING; this.f3713c = cVar3; try { this.f3711a.execute(this.f3715e); if (this.f3713c != cVar3) { return; } synchronized (this.f3712b) { if (this.f3714d == j10 && this.f3713c == cVar3) { this.f3713c = cVar; } } return; } catch (Error | RuntimeException e10) { synchronized (this.f3712b) { c cVar4 = this.f3713c; if ((cVar4 != c.IDLE && cVar4 != c.QUEUING) || !this.f3712b.removeLastOccurrence(aVar)) { r0 = false; } if (!(e10 instanceof RejectedExecutionException) || r0) { throw e10; } } return; } } this.f3712b.add(runnable); } } public String toString() { return "SequentialExecutor@" + System.identityHashCode(this) + "{" + this.f3711a + "}"; } }