package h5; import com.google.android.gms.common.api.Api; import h5.u0; import java.util.ArrayDeque; import java.util.Deque; import java.util.Iterator; import java.util.concurrent.ExecutorService; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /* loaded from: classes2.dex */ public final class r { /* renamed from: c, reason: collision with root package name */ private Runnable f10278c; /* renamed from: d, reason: collision with root package name */ private ExecutorService f10279d; /* renamed from: a, reason: collision with root package name */ private int f10276a = 64; /* renamed from: b, reason: collision with root package name */ private int f10277b = 5; /* renamed from: e, reason: collision with root package name */ private final Deque f10280e = new ArrayDeque(); /* renamed from: f, reason: collision with root package name */ private final Deque f10281f = new ArrayDeque(); /* renamed from: g, reason: collision with root package name */ private final Deque f10282g = new ArrayDeque(); private void a() { if (this.f10281f.size() < this.f10276a && !this.f10280e.isEmpty()) { Iterator it = this.f10280e.iterator(); while (it.hasNext()) { u0.a aVar = (u0.a) it.next(); if (e(aVar) < this.f10277b) { it.remove(); this.f10281f.add(aVar); f().execute(aVar); } if (this.f10281f.size() >= this.f10276a) { return; } } } } private void c(Deque deque, Object obj, boolean z10) { int g10; Runnable runnable; synchronized (this) { if (!deque.remove(obj)) { throw new AssertionError("Call wasn't in-flight!"); } if (z10) { a(); } g10 = g(); runnable = this.f10278c; } if (g10 != 0 || runnable == null) { return; } runnable.run(); } private int e(u0.a aVar) { int i10 = 0; for (u0.a aVar2 : this.f10281f) { if (!aVar2.k().f10304e && aVar2.l().equals(aVar.l())) { i10++; } } return i10; } synchronized void b(u0.a aVar) { if (this.f10281f.size() >= this.f10276a || e(aVar) >= this.f10277b) { this.f10280e.add(aVar); } else { this.f10281f.add(aVar); f().execute(aVar); } } void d(u0.a aVar) { c(this.f10281f, aVar, true); } public synchronized ExecutorService f() { if (this.f10279d == null) { this.f10279d = new ThreadPoolExecutor(0, Api.BaseClientBuilder.API_PRIORITY_OTHER, 60L, TimeUnit.SECONDS, new SynchronousQueue(), i5.c.D("OkHttp Dispatcher", false)); } return this.f10279d; } public synchronized int g() { return this.f10281f.size() + this.f10282g.size(); } }