package p461;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.concurrent.TimeUnit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p402.InterfaceC6540;
import p402.p411.p413.C6635;

/* JADX INFO: renamed from: ޑ.ؠ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public class C7098 extends C7130 {

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public static C7098 f20620;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public boolean f20622;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public C7098 f20623;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public long f20624;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public static final C7099 f20621 = new C7099(null);

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static final long f20618 = TimeUnit.SECONDS.toMillis(60);

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public static final long f20619 = TimeUnit.MILLISECONDS.toNanos(f20618);

    /* JADX INFO: renamed from: ޑ.ؠ$֏, reason: contains not printable characters */
    public static final class C7099 {
        public C7099() {
        }

        public /* synthetic */ C7099(DefaultConstructorMarker defaultConstructorMarker) {
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C7098 m10401() throws InterruptedException {
            C7098 c7098 = C7098.f20620;
            if (c7098 == null) {
                C6635.m9822();
                throw null;
            }
            C7098 c70982 = c7098.f20623;
            if (c70982 == null) {
                long jNanoTime = System.nanoTime();
                C7098.class.wait(C7098.f20618);
                C7098 c70983 = C7098.f20620;
                if (c70983 == null) {
                    C6635.m9822();
                    throw null;
                }
                if (c70983.f20623 != null || System.nanoTime() - jNanoTime < C7098.f20619) {
                    return null;
                }
                return C7098.f20620;
            }
            long jNanoTime2 = c70982.f20624 - System.nanoTime();
            if (jNanoTime2 > 0) {
                long j = jNanoTime2 / 1000000;
                C7098.class.wait(j, (int) (jNanoTime2 - (1000000 * j)));
                return null;
            }
            C7098 c70984 = C7098.f20620;
            if (c70984 == null) {
                C6635.m9822();
                throw null;
            }
            c70984.f20623 = c70982.f20623;
            c70982.f20623 = null;
            return c70982;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10402(C7098 c7098, long j, boolean z) {
            synchronized (C7098.class) {
                if (C7098.f20620 == null) {
                    C7098.f20620 = new C7098();
                    new C7100().start();
                }
                long jNanoTime = System.nanoTime();
                if (j != 0 && z) {
                    c7098.f20624 = Math.min(j, c7098.mo10462() - jNanoTime) + jNanoTime;
                } else if (j != 0) {
                    c7098.f20624 = j + jNanoTime;
                } else {
                    if (!z) {
                        throw new AssertionError();
                    }
                    c7098.f20624 = c7098.mo10462();
                }
                long j2 = c7098.f20624 - jNanoTime;
                C7098 c70982 = C7098.f20620;
                if (c70982 == null) {
                    C6635.m9822();
                    throw null;
                }
                while (c70982.f20623 != null) {
                    C7098 c70983 = c70982.f20623;
                    if (c70983 == null) {
                        C6635.m9822();
                        throw null;
                    }
                    if (j2 < c70983.f20624 - jNanoTime) {
                        break;
                    }
                    c70982 = c70982.f20623;
                    if (c70982 == null) {
                        C6635.m9822();
                        throw null;
                    }
                }
                c7098.f20623 = c70982.f20623;
                c70982.f20623 = c7098;
                if (c70982 == C7098.f20620) {
                    C7098.class.notify();
                }
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final boolean m10403(C7098 c7098) {
            synchronized (C7098.class) {
                for (C7098 c70982 = C7098.f20620; c70982 != null; c70982 = c70982.f20623) {
                    if (c70982.f20623 == c7098) {
                        c70982.f20623 = c7098.f20623;
                        c7098.f20623 = null;
                        return false;
                    }
                }
                return true;
            }
        }
    }

    /* JADX INFO: renamed from: ޑ.ؠ$ؠ, reason: contains not printable characters */
    public static final class C7100 extends Thread {
        public C7100() {
            super("Okio Watchdog");
            setDaemon(true);
        }

        @Override // java.lang.Thread, java.lang.Runnable
        public void run() {
            C7098 c7098M10401;
            while (true) {
                try {
                    synchronized (C7098.class) {
                        c7098M10401 = C7098.f20621.m10401();
                        if (c7098M10401 == C7098.f20620) {
                            C7098.f20620 = null;
                            return;
                        }
                    }
                    if (c7098M10401 != null) {
                        c7098M10401.mo10225();
                    }
                } catch (InterruptedException unused) {
                }
            }
        }
    }

    /* JADX INFO: renamed from: ֏ */
    public IOException mo10342(IOException iOException) {
        InterruptedIOException interruptedIOException = new InterruptedIOException("timeout");
        if (iOException != null) {
            interruptedIOException.initCause(iOException);
        }
        return interruptedIOException;
    }

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final void m10399() {
        if (!(!this.f20622)) {
            throw new IllegalStateException("Unbalanced enter/exit".toString());
        }
        long j = this.f20682;
        boolean z = this.f20680;
        if (j != 0 || z) {
            this.f20622 = true;
            f20621.m10402(this, j, z);
        }
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final boolean m10400() {
        if (!this.f20622) {
            return false;
        }
        this.f20622 = false;
        return f20621.m10403(this);
    }

    /* JADX INFO: renamed from: ޅ */
    public void mo10225() {
    }
}
