package p138.p145.p146.p151.p154.p156;

import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import p000.p001.p002.p003.p004.C0567;

/* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ފ.ޚ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C2964 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Map<String, C2965> f9114 = new HashMap();

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C2966 f9115 = new C2966();

    /* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ފ.ޚ.ހ$֏, reason: contains not printable characters */
    public static class C2965 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final Lock f9116 = new ReentrantLock();

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int f9117;
    }

    /* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ފ.ޚ.ހ$ؠ, reason: contains not printable characters */
    public static class C2966 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final Queue<C2965> f9118 = new ArrayDeque();

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public C2965 m5119() {
            C2965 c2965Poll;
            synchronized (this.f9118) {
                c2965Poll = this.f9118.poll();
            }
            return c2965Poll == null ? new C2965() : c2965Poll;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void m5120(C2965 c2965) {
            synchronized (this.f9118) {
                if (this.f9118.size() < 10) {
                    this.f9118.offer(c2965);
                }
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m5117(String str) {
        C2965 c2965M5119;
        synchronized (this) {
            c2965M5119 = this.f9114.get(str);
            if (c2965M5119 == null) {
                c2965M5119 = this.f9115.m5119();
                this.f9114.put(str, c2965M5119);
            }
            c2965M5119.f9117++;
        }
        c2965M5119.f9116.lock();
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public void m5118(String str) {
        C2965 c2965;
        synchronized (this) {
            C2965 c29652 = this.f9114.get(str);
            C0567.m1858(c29652, "Argument must not be null");
            c2965 = c29652;
            if (c2965.f9117 < 1) {
                throw new IllegalStateException("Cannot release a lock that is not held, safeKey: " + str + ", interestedThreads: " + c2965.f9117);
            }
            int i = c2965.f9117 - 1;
            c2965.f9117 = i;
            if (i == 0) {
                C2965 c2965Remove = this.f9114.remove(str);
                if (!c2965Remove.equals(c2965)) {
                    throw new IllegalStateException("Removed the wrong lock, expected to remove: " + c2965 + ", but actually removed: " + c2965Remove + ", safeKey: " + str);
                }
                this.f9115.m5120(c2965Remove);
            }
        }
        c2965.f9116.unlock();
    }
}
