package 㴹.K.Ԕ.ⁱ;

import io.reactivex.internal.disposables.EmptyDisposable;
import io.reactivex.internal.schedulers.RxThreadFactory;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import 㴹.K.AbstractC2508;
import 㴹.K.Ԕ.K.C2485;
import 㴹.K.㑃.AbstractC2514;
import 㴹.K.㑃.C2515;

/* renamed from: 㴹.K.Ԕ.ⁱ.K  reason: contains not printable characters */
/* compiled from: ComputationScheduler */
public final class C2473 extends AbstractC2508 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static final C2475 f8442 = new C2475(0, f8445);

    /* renamed from: ඓ  reason: contains not printable characters */
    public static final int f8443;

    /* renamed from: 㴹  reason: contains not printable characters */
    public static final C2474 f8444 = new C2474(new RxThreadFactory("RxComputationShutdown"));

    /* renamed from: 㸾  reason: contains not printable characters */
    public static final RxThreadFactory f8445 = new RxThreadFactory("RxComputationThreadPool", Math.max(1, Math.min(10, Integer.getInteger("rx2.computation-priority", 5).intValue())), true);

    /* renamed from: ῲ  reason: contains not printable characters */
    public final AtomicReference<C2475> f8446 = new AtomicReference<>(f8442);

    /* renamed from: K  reason: contains not printable characters */
    public final ThreadFactory f8447 = f8445;

    /* renamed from: 㴹.K.Ԕ.ⁱ.K$ʬ  reason: contains not printable characters */
    /* compiled from: ComputationScheduler */
    public static final class C2474 extends C2479 {
        public C2474(ThreadFactory threadFactory) {
            super(threadFactory);
        }
    }

    /* renamed from: 㴹.K.Ԕ.ⁱ.K$ῲ  reason: contains not printable characters */
    /* compiled from: ComputationScheduler */
    public static final class C2475 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public long f8448;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final C2474[] f8449;

        /* renamed from: K  reason: contains not printable characters */
        public final int f8450;

        public C2475(int i, ThreadFactory threadFactory) {
            this.f8450 = i;
            this.f8449 = new C2474[i];
            for (int i2 = 0; i2 < i; i2++) {
                this.f8449[i2] = new C2474(threadFactory);
            }
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public void m6513() {
            for (C2474 r3 : this.f8449) {
                r3.dispose();
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public C2474 m6514() {
            int i = this.f8450;
            if (i == 0) {
                return C2473.f8444;
            }
            C2474[] r1 = this.f8449;
            long j = this.f8448;
            this.f8448 = 1 + j;
            return r1[(int) (j % ((long) i))];
        }
    }

    static {
        int availableProcessors = Runtime.getRuntime().availableProcessors();
        int intValue = Integer.getInteger("rx2.computation-threads", 0).intValue();
        if (intValue > 0 && intValue <= availableProcessors) {
            availableProcessors = intValue;
        }
        f8443 = availableProcessors;
        f8444.dispose();
        for (C2474 r3 : f8442.f8449) {
            r3.dispose();
        }
    }

    public C2473() {
        C2475 r0 = new C2475(f8443, this.f8447);
        if (!this.f8446.compareAndSet(f8442, r0)) {
            r0.m6513();
        }
    }

    @Override // 㴹.K.AbstractC2508
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC2508.AbstractC2509 m6511() {
        return new C2476(this.f8446.get().m6514());
    }

    @Override // 㴹.K.AbstractC2508
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC2514 m6512(Runnable runnable, long j, TimeUnit timeUnit) {
        return this.f8446.get().m6514().m6518(runnable, j, timeUnit);
    }

    /* renamed from: 㴹.K.Ԕ.ⁱ.K$K  reason: contains not printable characters */
    /* compiled from: ComputationScheduler */
    public static final class C2476 extends AbstractC2508.AbstractC2509 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final C2515 f8451 = new C2515();

        /* renamed from: ඓ  reason: contains not printable characters */
        public final C2474 f8452;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final C2485 f8453 = new C2485();

        /* renamed from: 㴹  reason: contains not printable characters */
        public volatile boolean f8454;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final C2485 f8455 = new C2485();

        public C2476(C2474 r2) {
            this.f8452 = r2;
            this.f8455.m6528(this.f8453);
            this.f8455.m6528(this.f8451);
        }

        @Override // 㴹.K.㑃.AbstractC2514
        public void dispose() {
            if (!this.f8454) {
                this.f8454 = true;
                this.f8455.dispose();
            }
        }

        @Override // 㴹.K.㑃.AbstractC2514
        public boolean isDisposed() {
            return this.f8454;
        }

        @Override // 㴹.K.AbstractC2508.AbstractC2509
        /* renamed from: K  reason: contains not printable characters */
        public AbstractC2514 m6515(Runnable runnable) {
            if (this.f8454) {
                return EmptyDisposable.INSTANCE;
            }
            return this.f8452.m6519(runnable, 0, TimeUnit.MILLISECONDS, this.f8453);
        }

        @Override // 㴹.K.AbstractC2508.AbstractC2509
        /* renamed from: K  reason: contains not printable characters */
        public AbstractC2514 m6516(Runnable runnable, long j, TimeUnit timeUnit) {
            if (this.f8454) {
                return EmptyDisposable.INSTANCE;
            }
            return this.f8452.m6519(runnable, j, timeUnit, this.f8451);
        }
    }
}
