package okio;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\t\b\u0016\u0018\u0000 &2\u00020\u0001:\u0002&'B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u0017\u0010\u0006\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0004H\u0002¢\u0006\u0004\b\u0006\u0010\u0007J\r\u0010\t\u001a\u00020\b¢\u0006\u0004\b\t\u0010\u0003J\r\u0010\u000b\u001a\u00020\n¢\u0006\u0004\b\u000b\u0010\fJ\u000f\u0010\r\u001a\u00020\bH\u0016¢\u0006\u0004\b\r\u0010\u0003J\u000f\u0010\u000e\u001a\u00020\bH\u0014¢\u0006\u0004\b\u000e\u0010\u0003J\u0015\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u000f¢\u0006\u0004\b\u0010\u0010\u0011J\u0015\u0010\u0013\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u0012¢\u0006\u0004\b\u0013\u0010\u0014J'\u0010\u0018\u001a\u00028\u0000\"\u0004\b\u0000\u0010\u00152\f\u0010\u0017\u001a\b\u0012\u0004\u0012\u00028\u00000\u0016H\u0086\bø\u0001\u0000¢\u0006\u0004\b\u0018\u0010\u0019J\u0019\u0010\u001c\u001a\u00020\u001a2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001aH\u0001¢\u0006\u0004\b\u001c\u0010\u001dJ\u0019\u0010\u001e\u001a\u00020\u001a2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001aH\u0014¢\u0006\u0004\b\u001e\u0010\u001dR\u0016\u0010 \u001a\u00020\u001f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b \u0010!R\u0018\u0010\"\u001a\u0004\u0018\u00010\u00008\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\"\u0010#R\u0016\u0010$\u001a\u00020\u00048\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b$\u0010%\u0082\u0002\u0007\n\u0005\b\u009920\u0001¨\u0006("}, d2 = {"Lokio/AsyncTimeout;", "Lokio/Timeout;", "<init>", "()V", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "now", "a", "(J)J", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "enter", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "exit", "()Z", "cancel", "timedOut", "Lokio/Sink;", "sink", "(Lokio/Sink;)Lokio/Sink;", "Lokio/Source;", "source", "(Lokio/Source;)Lokio/Source;", "T", "Lkotlin/Function0;", "block", "withTimeout", "(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;", "Ljava/io/IOException;", "cause", "access$newTimeoutException", "(Ljava/io/IOException;)Ljava/io/IOException;", "newTimeoutException", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "state", "I", "next", "Lokio/AsyncTimeout;", "timeoutAt", "J", "Companion", "Watchdog", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public class AsyncTimeout extends okio.Timeout {

    @org.jetbrains.annotations.NotNull
    private static final okio.AsyncTimeout.Companion Companion = new okio.AsyncTimeout.Companion(null);
    private static final long IDLE_TIMEOUT_MILLIS;
    private static final long IDLE_TIMEOUT_NANOS;
    private static final int STATE_CANCELED = 3;
    private static final int STATE_IDLE = 0;
    private static final int STATE_IN_QUEUE = 1;
    private static final int STATE_TIMED_OUT = 2;
    private static final int TIMEOUT_WRITE_SIZE = 65536;

    @org.jetbrains.annotations.NotNull
    private static final java.util.concurrent.locks.Condition condition;

    @org.jetbrains.annotations.Nullable
    private static okio.AsyncTimeout head;

    @org.jetbrains.annotations.NotNull
    private static final java.util.concurrent.locks.ReentrantLock lock;

    @org.jetbrains.annotations.Nullable
    private okio.AsyncTimeout next;
    private int state;
    private long timeoutAt;

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000>\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\b\n\u0002\b\t\b\u0082\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J'\u0010\u000b\u001a\u00020\n2\u0006\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\bH\u0002¢\u0006\u0004\b\u000b\u0010\fJ\u0017\u0010\r\u001a\u00020\n2\u0006\u0010\u0005\u001a\u00020\u0004H\u0002¢\u0006\u0004\b\r\u0010\u000eJ\u000f\u0010\u000f\u001a\u0004\u0018\u00010\u0004¢\u0006\u0004\b\u000f\u0010\u0010R\u0017\u0010\u0012\u001a\u00020\u00118\u0006¢\u0006\f\n\u0004\b\u0012\u0010\u0013\u001a\u0004\b\u0014\u0010\u0015R\u0017\u0010\u0017\u001a\u00020\u00168\u0006¢\u0006\f\n\u0004\b\u0017\u0010\u0018\u001a\u0004\b\u0019\u0010\u001aR\u0014\u0010\u001b\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u001b\u0010\u001cR\u0014\u0010\u001d\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u001d\u0010\u001cR\u0014\u0010\u001f\u001a\u00020\u001e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u001f\u0010 R\u0014\u0010!\u001a\u00020\u001e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b!\u0010 R\u0014\u0010\"\u001a\u00020\u001e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b\"\u0010 R\u0014\u0010#\u001a\u00020\u001e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b#\u0010 R\u0014\u0010$\u001a\u00020\u001e8\u0002X\u0082T¢\u0006\u0006\n\u0004\b$\u0010 R\u0018\u0010%\u001a\u0004\u0018\u00010\u00048\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b%\u0010&¨\u0006'"}, d2 = {"Lokio/AsyncTimeout$Companion;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "<init>", "()V", "Lokio/AsyncTimeout;", "node", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "timeoutNanos", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "hasDeadline", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "f", "(Lokio/AsyncTimeout;JZ)V", "g", "(Lokio/AsyncTimeout;)V", "c", "()Lokio/AsyncTimeout;", "Ljava/util/concurrent/locks/ReentrantLock;", "lock", "Ljava/util/concurrent/locks/ReentrantLock;", "e", "()Ljava/util/concurrent/locks/ReentrantLock;", "Ljava/util/concurrent/locks/Condition;", "condition", "Ljava/util/concurrent/locks/Condition;", "d", "()Ljava/util/concurrent/locks/Condition;", "IDLE_TIMEOUT_MILLIS", "J", "IDLE_TIMEOUT_NANOS", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "STATE_CANCELED", "I", "STATE_IDLE", "STATE_IN_QUEUE", "STATE_TIMED_OUT", "TIMEOUT_WRITE_SIZE", "head", "Lokio/AsyncTimeout;", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
    private static final class Companion {
        public /* synthetic */ Companion(kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        /* JADX INFO: Access modifiers changed from: private */
        public final void f(okio.AsyncTimeout node, long timeoutNanos, boolean hasDeadline) {
            if (okio.AsyncTimeout.head == null) {
                okio.AsyncTimeout.head = new okio.AsyncTimeout();
                new okio.AsyncTimeout.Watchdog().start();
            }
            long jNanoTime = java.lang.System.nanoTime();
            if (timeoutNanos != 0 && hasDeadline) {
                node.timeoutAt = java.lang.Math.min(timeoutNanos, node.deadlineNanoTime() - jNanoTime) + jNanoTime;
            } else if (timeoutNanos != 0) {
                node.timeoutAt = timeoutNanos + jNanoTime;
            } else {
                if (!hasDeadline) {
                    throw new java.lang.AssertionError();
                }
                node.timeoutAt = node.deadlineNanoTime();
            }
            long jA = node.a(jNanoTime);
            okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.head;
            kotlin.jvm.internal.Intrinsics.i(asyncTimeout);
            while (asyncTimeout.next != null) {
                okio.AsyncTimeout asyncTimeout2 = asyncTimeout.next;
                kotlin.jvm.internal.Intrinsics.i(asyncTimeout2);
                if (jA < asyncTimeout2.a(jNanoTime)) {
                    break;
                }
                asyncTimeout = asyncTimeout.next;
                kotlin.jvm.internal.Intrinsics.i(asyncTimeout);
            }
            node.next = asyncTimeout.next;
            asyncTimeout.next = node;
            if (asyncTimeout == okio.AsyncTimeout.head) {
                d().signal();
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public final void g(okio.AsyncTimeout node) {
            for (okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.head; asyncTimeout != null; asyncTimeout = asyncTimeout.next) {
                if (asyncTimeout.next == node) {
                    asyncTimeout.next = node.next;
                    node.next = null;
                    return;
                }
            }
            throw new java.lang.IllegalStateException("node was not found in the queue");
        }

        public final okio.AsyncTimeout c() throws java.lang.InterruptedException {
            okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.head;
            kotlin.jvm.internal.Intrinsics.i(asyncTimeout);
            okio.AsyncTimeout asyncTimeout2 = asyncTimeout.next;
            if (asyncTimeout2 == null) {
                long jNanoTime = java.lang.System.nanoTime();
                d().await(okio.AsyncTimeout.IDLE_TIMEOUT_MILLIS, java.util.concurrent.TimeUnit.MILLISECONDS);
                okio.AsyncTimeout asyncTimeout3 = okio.AsyncTimeout.head;
                kotlin.jvm.internal.Intrinsics.i(asyncTimeout3);
                if (asyncTimeout3.next != null || java.lang.System.nanoTime() - jNanoTime < okio.AsyncTimeout.IDLE_TIMEOUT_NANOS) {
                    return null;
                }
                return okio.AsyncTimeout.head;
            }
            long jA = asyncTimeout2.a(java.lang.System.nanoTime());
            if (jA > 0) {
                d().await(jA, java.util.concurrent.TimeUnit.NANOSECONDS);
                return null;
            }
            okio.AsyncTimeout asyncTimeout4 = okio.AsyncTimeout.head;
            kotlin.jvm.internal.Intrinsics.i(asyncTimeout4);
            asyncTimeout4.next = asyncTimeout2.next;
            asyncTimeout2.next = null;
            asyncTimeout2.state = 2;
            return asyncTimeout2;
        }

        public final java.util.concurrent.locks.Condition d() {
            return okio.AsyncTimeout.condition;
        }

        public final java.util.concurrent.locks.ReentrantLock e() {
            return okio.AsyncTimeout.lock;
        }

        private Companion() {
        }
    }

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0003\u001a\u00020\u0004H\u0016¨\u0006\u0005"}, d2 = {"Lokio/AsyncTimeout$Watchdog;", "Ljava/lang/Thread;", "()V", "run", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
    private static final class Watchdog extends java.lang.Thread {
        public Watchdog() {
            super("Okio Watchdog");
            setDaemon(true);
        }

        @Override // java.lang.Thread, java.lang.Runnable
        public void run() {
            while (true) {
                try {
                    java.util.concurrent.locks.ReentrantLock reentrantLockE = okio.AsyncTimeout.Companion.e();
                    reentrantLockE.lock();
                    try {
                        okio.AsyncTimeout asyncTimeoutC = okio.AsyncTimeout.Companion.c();
                        if (asyncTimeoutC == okio.AsyncTimeout.head) {
                            okio.AsyncTimeout.Companion unused = okio.AsyncTimeout.Companion;
                            okio.AsyncTimeout.head = null;
                            reentrantLockE.unlock();
                            return;
                        } else {
                            kotlin.Unit unit = kotlin.Unit.a;
                            reentrantLockE.unlock();
                            if (asyncTimeoutC != null) {
                                asyncTimeoutC.timedOut();
                            }
                        }
                    } catch (java.lang.Throwable th) {
                        reentrantLockE.unlock();
                        throw th;
                    }
                } catch (java.lang.InterruptedException unused2) {
                    continue;
                }
            }
        }
    }

    static {
        java.util.concurrent.locks.ReentrantLock reentrantLock = new java.util.concurrent.locks.ReentrantLock();
        lock = reentrantLock;
        java.util.concurrent.locks.Condition conditionNewCondition = reentrantLock.newCondition();
        kotlin.jvm.internal.Intrinsics.k(conditionNewCondition, "newCondition(...)");
        condition = conditionNewCondition;
        long millis = java.util.concurrent.TimeUnit.SECONDS.toMillis(60L);
        IDLE_TIMEOUT_MILLIS = millis;
        IDLE_TIMEOUT_NANOS = java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(millis);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final long a(long now) {
        return this.timeoutAt - now;
    }

    @kotlin.PublishedApi
    @org.jetbrains.annotations.NotNull
    public final java.io.IOException access$newTimeoutException(@org.jetbrains.annotations.Nullable java.io.IOException cause) {
        return newTimeoutException(cause);
    }

    @Override // okio.Timeout
    public void cancel() {
        super.cancel();
        java.util.concurrent.locks.ReentrantLock reentrantLock = lock;
        reentrantLock.lock();
        try {
            if (this.state == 1) {
                Companion.g(this);
                this.state = 3;
            }
            kotlin.Unit unit = kotlin.Unit.a;
        } finally {
            reentrantLock.unlock();
        }
    }

    public final void enter() {
        long timeoutNanos = getTimeoutNanos();
        boolean hasDeadline = getHasDeadline();
        if (timeoutNanos != 0 || hasDeadline) {
            java.util.concurrent.locks.ReentrantLock reentrantLock = lock;
            reentrantLock.lock();
            try {
                if (this.state != 0) {
                    throw new java.lang.IllegalStateException("Unbalanced enter/exit");
                }
                this.state = 1;
                Companion.f(this, timeoutNanos, hasDeadline);
                kotlin.Unit unit = kotlin.Unit.a;
                reentrantLock.unlock();
            } catch (java.lang.Throwable th) {
                reentrantLock.unlock();
                throw th;
            }
        }
    }

    public final boolean exit() {
        java.util.concurrent.locks.ReentrantLock reentrantLock = lock;
        reentrantLock.lock();
        try {
            int i = this.state;
            this.state = 0;
            if (i != 1) {
                return i == 2;
            }
            Companion.g(this);
            return false;
        } finally {
            reentrantLock.unlock();
        }
    }

    @org.jetbrains.annotations.NotNull
    protected java.io.IOException newTimeoutException(@org.jetbrains.annotations.Nullable java.io.IOException cause) {
        java.io.InterruptedIOException interruptedIOException = new java.io.InterruptedIOException("timeout");
        if (cause != null) {
            interruptedIOException.initCause(cause);
        }
        return interruptedIOException;
    }

    @org.jetbrains.annotations.NotNull
    public final okio.Sink sink(@org.jetbrains.annotations.NotNull final okio.Sink sink) {
        kotlin.jvm.internal.Intrinsics.l(sink, "sink");
        return new okio.Sink() { // from class: okio.AsyncTimeout.sink.1
            @Override // okio.Sink
            /* JADX INFO: renamed from: a, reason: from getter and merged with bridge method [inline-methods] */
            public okio.AsyncTimeout timeout() {
                return okio.AsyncTimeout.this;
            }

            @Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
            public void close() throws java.io.IOException {
                okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.this;
                okio.Sink sink2 = sink;
                asyncTimeout.enter();
                try {
                    try {
                        sink2.close();
                        kotlin.Unit unit = kotlin.Unit.a;
                        if (asyncTimeout.exit()) {
                            throw asyncTimeout.access$newTimeoutException(null);
                        }
                    } catch (java.io.IOException e) {
                        if (!asyncTimeout.exit()) {
                            throw e;
                        }
                        throw asyncTimeout.access$newTimeoutException(e);
                    }
                } catch (java.lang.Throwable th) {
                    asyncTimeout.exit();
                    throw th;
                }
            }

            @Override // okio.Sink, java.io.Flushable
            public void flush() throws java.io.IOException {
                okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.this;
                okio.Sink sink2 = sink;
                asyncTimeout.enter();
                try {
                    try {
                        sink2.flush();
                        kotlin.Unit unit = kotlin.Unit.a;
                        if (asyncTimeout.exit()) {
                            throw asyncTimeout.access$newTimeoutException(null);
                        }
                    } catch (java.io.IOException e) {
                        if (!asyncTimeout.exit()) {
                            throw e;
                        }
                        throw asyncTimeout.access$newTimeoutException(e);
                    }
                } catch (java.lang.Throwable th) {
                    asyncTimeout.exit();
                    throw th;
                }
            }

            public java.lang.String toString() {
                return "AsyncTimeout.sink(" + sink + ')';
            }

            @Override // okio.Sink
            public void write(okio.Buffer source, long byteCount) throws java.io.IOException {
                kotlin.jvm.internal.Intrinsics.l(source, "source");
                okio.SegmentedByteString.b(source.getSize(), 0L, byteCount);
                while (true) {
                    long j = 0;
                    if (byteCount <= 0) {
                        return;
                    }
                    okio.Segment segment = source.head;
                    kotlin.jvm.internal.Intrinsics.i(segment);
                    while (j < 65536) {
                        j += (long) (segment.limit - segment.pos);
                        if (j >= byteCount) {
                            j = byteCount;
                            break;
                        } else {
                            segment = segment.next;
                            kotlin.jvm.internal.Intrinsics.i(segment);
                        }
                    }
                    okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.this;
                    okio.Sink sink2 = sink;
                    asyncTimeout.enter();
                    try {
                        try {
                            sink2.write(source, j);
                            kotlin.Unit unit = kotlin.Unit.a;
                            if (asyncTimeout.exit()) {
                                throw asyncTimeout.access$newTimeoutException(null);
                            }
                            byteCount -= j;
                        } catch (java.io.IOException e) {
                            if (!asyncTimeout.exit()) {
                                throw e;
                            }
                            throw asyncTimeout.access$newTimeoutException(e);
                        }
                    } catch (java.lang.Throwable th) {
                        asyncTimeout.exit();
                        throw th;
                    }
                }
            }
        };
    }

    @org.jetbrains.annotations.NotNull
    public final okio.Source source(@org.jetbrains.annotations.NotNull final okio.Source source) {
        kotlin.jvm.internal.Intrinsics.l(source, "source");
        return new okio.Source() { // from class: okio.AsyncTimeout.source.1
            @Override // okio.Source
            /* JADX INFO: renamed from: a, reason: from getter and merged with bridge method [inline-methods] */
            public okio.AsyncTimeout timeout() {
                return okio.AsyncTimeout.this;
            }

            @Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
            public void close() throws java.io.IOException {
                okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.this;
                okio.Source source2 = source;
                asyncTimeout.enter();
                try {
                    try {
                        source2.close();
                        kotlin.Unit unit = kotlin.Unit.a;
                        if (asyncTimeout.exit()) {
                            throw asyncTimeout.access$newTimeoutException(null);
                        }
                    } catch (java.io.IOException e) {
                        if (!asyncTimeout.exit()) {
                            throw e;
                        }
                        throw asyncTimeout.access$newTimeoutException(e);
                    }
                } catch (java.lang.Throwable th) {
                    asyncTimeout.exit();
                    throw th;
                }
            }

            @Override // okio.Source
            public long read(okio.Buffer sink, long byteCount) throws java.io.IOException {
                kotlin.jvm.internal.Intrinsics.l(sink, "sink");
                okio.AsyncTimeout asyncTimeout = okio.AsyncTimeout.this;
                okio.Source source2 = source;
                asyncTimeout.enter();
                try {
                    try {
                        long j = source2.read(sink, byteCount);
                        if (asyncTimeout.exit()) {
                            throw asyncTimeout.access$newTimeoutException(null);
                        }
                        return j;
                    } catch (java.io.IOException e) {
                        if (asyncTimeout.exit()) {
                            throw asyncTimeout.access$newTimeoutException(e);
                        }
                        throw e;
                    }
                } catch (java.lang.Throwable th) {
                    asyncTimeout.exit();
                    throw th;
                }
            }

            public java.lang.String toString() {
                return "AsyncTimeout.source(" + source + ')';
            }
        };
    }

    public final <T> T withTimeout(@org.jetbrains.annotations.NotNull kotlin.jvm.functions.Function0<? extends T> block) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(block, "block");
        enter();
        try {
            try {
                T t = (T) block.invoke();
                kotlin.jvm.internal.InlineMarker.b(1);
                if (exit()) {
                    throw access$newTimeoutException(null);
                }
                kotlin.jvm.internal.InlineMarker.a(1);
                return t;
            } catch (java.io.IOException e) {
                if (exit()) {
                    throw access$newTimeoutException(e);
                }
                throw e;
            }
        } catch (java.lang.Throwable th) {
            kotlin.jvm.internal.InlineMarker.b(1);
            exit();
            kotlin.jvm.internal.InlineMarker.a(1);
            throw th;
        }
    }

    protected void timedOut() {
    }
}
