package ඓ.ῲ.K.ᕣ.ᨨ;

import android.os.Process;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import ඓ.ῲ.K.ᕣ.AbstractC1029;
import ඓ.ῲ.K.ᕣ.ᨨ.C1005;
import ῲ.ᨨ.㳳.C1841;

/* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.K  reason: contains not printable characters */
/* compiled from: ActiveResources */
public final class C0957 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final ReferenceQueue<C1005<?>> f4320 = new ReferenceQueue<>();

    /* renamed from: ඓ  reason: contains not printable characters */
    public volatile boolean f4321;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final Map<AbstractC1029, C0958> f4322 = new HashMap();

    /* renamed from: K  reason: contains not printable characters */
    public final boolean f4323;

    /* renamed from: 㸾  reason: contains not printable characters */
    public C1005.AbstractC1006 f4324;

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.K$ῲ  reason: contains not printable characters */
    /* compiled from: ActiveResources */
    public static final class C0958 extends WeakReference<C1005<?>> {

        /* renamed from: ʬ  reason: contains not printable characters */
        public AbstractC1027<?> f4325;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final boolean f4326;

        /* renamed from: K  reason: contains not printable characters */
        public final AbstractC1029 f4327;

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX DEBUG: Type inference failed for r1v4. Raw type applied. Possible types: ඓ.ῲ.K.ᕣ.ᨨ.䀟<Z> */
        public C0958(AbstractC1029 r1, C1005<?> r2, ReferenceQueue<? super C1005<?>> referenceQueue, boolean z) {
            super(r2, referenceQueue);
            AbstractC1027 r12;
            C1841.m4783(r1, "Argument must not be null");
            this.f4327 = r1;
            if (!r2.f4402 || !z) {
                r12 = (AbstractC1027<Z>) false;
            } else {
                AbstractC1027 r13 = (AbstractC1027<Z>) r2.f4405;
                C1841.m4783(r13, "Argument must not be null");
                r12 = r13;
            }
            this.f4325 = r12;
            this.f4326 = r2.f4402;
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.K$K  reason: contains not printable characters */
    /* compiled from: ActiveResources */
    public class ThreadFactoryC0959 implements ThreadFactory {

        /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.K$K$K  reason: contains not printable characters */
        /* compiled from: ActiveResources */
        public class RunnableC0960 implements Runnable {

            /* renamed from: ῲ  reason: contains not printable characters */
            public final /* synthetic */ Runnable f4328;

            public RunnableC0960(ThreadFactoryC0959 k, Runnable runnable) {
                this.f4328 = runnable;
            }

            public void run() {
                Process.setThreadPriority(10);
                this.f4328.run();
            }
        }

        public Thread newThread(Runnable runnable) {
            return new Thread(new RunnableC0960(this, runnable), "glide-active-resources");
        }
    }

    public C0957(boolean z) {
        ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryC0959());
        this.f4323 = z;
        newSingleThreadExecutor.execute(new RunnableC0955(this));
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public synchronized C1005<?> m2715(AbstractC1029 r2) {
        C0958 r22 = this.f4322.get(r2);
        if (r22 == null) {
            return null;
        }
        C1005<?> r0 = (C1005) r22.get();
        if (r0 == null) {
            m2716(r22);
        }
        return r0;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m2717(C1005.AbstractC1006 k) {
        synchronized (k) {
            synchronized (this) {
                this.f4324 = k;
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized void m2719(AbstractC1029 r4, C1005<?> r5) {
        C0958 put = this.f4322.put(r4, new C0958(r4, r5, this.f4320, this.f4323));
        if (put != null) {
            put.f4325 = null;
            put.clear();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized void m2718(AbstractC1029 r2) {
        C0958 remove = this.f4322.remove(r2);
        if (remove != null) {
            remove.f4325 = null;
            remove.clear();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m2716(C0958 r8) {
        synchronized (this) {
            this.f4322.remove(r8.f4327);
            if (r8.f4326) {
                AbstractC1027<?> r2 = r8.f4325;
                if (r2 != null) {
                    C1005<?> r0 = new C1005<>(r2, true, false, r8.f4327, this.f4324);
                    ((C1013) this.f4324).m2826(r8.f4327, r0);
                }
            }
        }
    }
}
