package 㿎;

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;
import 㿎.C2642;
import 㿎.ሽ.C2540;

/* renamed from: 㿎.Ԕ  reason: contains not printable characters */
/* compiled from: Dispatcher */
public final class C2530 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public Runnable f8527;

    /* renamed from: ඓ  reason: contains not printable characters */
    public final Deque<C2642.C2643> f8528 = new ArrayDeque();

    /* renamed from: ῲ  reason: contains not printable characters */
    public int f8529 = 5;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final Deque<C2642> f8530 = new ArrayDeque();

    /* renamed from: K  reason: contains not printable characters */
    public int f8531 = 64;

    /* renamed from: 㴹  reason: contains not printable characters */
    public final Deque<C2642.C2643> f8532 = new ArrayDeque();

    /* renamed from: 㸾  reason: contains not printable characters */
    public ExecutorService f8533;

    /* renamed from: ʬ  reason: contains not printable characters */
    public synchronized int m6575() {
        return this.f8532.size() + this.f8530.size();
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final void m6577() {
        if (this.f8532.size() < this.f8531 && !this.f8528.isEmpty()) {
            Iterator<C2642.C2643> it2 = this.f8528.iterator();
            while (it2.hasNext()) {
                C2642.C2643 next = it2.next();
                if (m6576(next) < this.f8529) {
                    it2.remove();
                    this.f8532.add(next);
                    m6578().execute(next);
                }
                if (this.f8532.size() >= this.f8531) {
                    return;
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized ExecutorService m6578() {
        if (this.f8533 == null) {
            this.f8533 = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue(), C2540.m6649("OkHttp Dispatcher", false));
        }
        return this.f8533;
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized void m6580(C2642.C2643 k) {
        if (this.f8532.size() >= this.f8531 || m6576(k) >= this.f8529) {
            this.f8528.add(k);
        } else {
            this.f8532.add(k);
            m6578().execute(k);
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final int m6576(C2642.C2643 k) {
        int i = 0;
        for (C2642.C2643 k2 : this.f8532) {
            C2642 r2 = C2642.this;
            if (!r2.f8978 && r2.f8975.f8985.f8542.equals(C2642.this.f8975.f8985.f8542)) {
                i++;
            }
        }
        return i;
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized void m6581(C2642 r2) {
        this.f8530.add(r2);
    }

    /* renamed from: K  reason: contains not printable characters */
    public final <T> void m6579(Deque<T> deque, T t, boolean z) {
        int r1;
        Runnable runnable;
        synchronized (this) {
            if (deque.remove(t)) {
                if (z) {
                    m6577();
                }
                r1 = m6575();
                runnable = this.f8527;
            } else {
                throw new AssertionError("Call wasn't in-flight!");
            }
        }
        if (r1 == 0 && runnable != null) {
            runnable.run();
        }
    }
}
