package 㴹.K.Ԕ.ⁱ;

import io.reactivex.internal.disposables.EmptyDisposable;
import io.reactivex.internal.schedulers.RxThreadFactory;
import io.reactivex.internal.schedulers.ScheduledDirectTask;
import io.reactivex.internal.schedulers.ScheduledRunnable;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import ඓ.ⁱ.K.ඓ.C1252;
import 㴹.K.AbstractC2508;
import 㴹.K.㑃.AbstractC2514;
import 㴹.K.㑃.C2515;

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

    /* renamed from: ʬ  reason: contains not printable characters */
    public static final ScheduledExecutorService f8436 = Executors.newScheduledThreadPool(0);

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

    /* renamed from: K  reason: contains not printable characters */
    public final AtomicReference<ScheduledExecutorService> f8438 = new AtomicReference<>();

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

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

        /* renamed from: ῲ  reason: contains not printable characters */
        public final ScheduledExecutorService f8440;

        /* renamed from: 㸾  reason: contains not printable characters */
        public volatile boolean f8441;

        public C2472(ScheduledExecutorService scheduledExecutorService) {
            this.f8440 = scheduledExecutorService;
        }

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

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

        @Override // 㴹.K.AbstractC2508.AbstractC2509
        /* renamed from: K  reason: contains not printable characters */
        public AbstractC2514 m6510(Runnable runnable, long j, TimeUnit timeUnit) {
            Future<?> future;
            if (this.f8441) {
                return EmptyDisposable.INSTANCE;
            }
            ScheduledRunnable scheduledRunnable = new ScheduledRunnable(C1252.m3339(runnable), this.f8439);
            this.f8439.m6564(scheduledRunnable);
            if (j <= 0) {
                try {
                    future = this.f8440.submit((Callable) scheduledRunnable);
                } catch (RejectedExecutionException e) {
                    dispose();
                    C1252.m3349(e);
                    return EmptyDisposable.INSTANCE;
                }
            } else {
                future = this.f8440.schedule((Callable) scheduledRunnable, j, timeUnit);
            }
            scheduledRunnable.setFuture(future);
            return scheduledRunnable;
        }
    }

    static {
        f8436.shutdown();
    }

    public C2471() {
        RxThreadFactory rxThreadFactory = f8437;
        this.f8438.lazySet(C2477.m6517(rxThreadFactory));
    }

    @Override // 㴹.K.AbstractC2508
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC2508.AbstractC2509 m6508() {
        return new C2472(this.f8438.get());
    }

    @Override // 㴹.K.AbstractC2508
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC2514 m6509(Runnable runnable, long j, TimeUnit timeUnit) {
        Future<?> future;
        ScheduledDirectTask scheduledDirectTask = new ScheduledDirectTask(C1252.m3339(runnable));
        if (j <= 0) {
            try {
                future = this.f8438.get().submit(scheduledDirectTask);
            } catch (RejectedExecutionException e) {
                C1252.m3349(e);
                return EmptyDisposable.INSTANCE;
            }
        } else {
            future = this.f8438.get().schedule(scheduledDirectTask, j, timeUnit);
        }
        scheduledDirectTask.setFuture(future);
        return scheduledDirectTask;
    }
}
