mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-24 16:12:29 -06:00
183 lines
8.3 KiB
Java
183 lines
8.3 KiB
Java
package okio;
|
|
|
|
import io.sentry.ProfilingTraceData;
|
|
import java.io.IOException;
|
|
import java.io.InterruptedIOException;
|
|
import java.util.concurrent.TimeUnit;
|
|
import kotlin.Metadata;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.InlineMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
|
|
/* compiled from: Timeout.kt */
|
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0016\u0018\u0000 \u00172\u00020\u0001:\u0001\u0017B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\b\u001a\u00020\u0000H\u0016J\b\u0010\t\u001a\u00020\u0000H\u0016J\u0016\u0010\n\u001a\u00020\u00002\u0006\u0010\u000b\u001a\u00020\u00042\u0006\u0010\f\u001a\u00020\rJ\b\u0010\u0003\u001a\u00020\u0004H\u0016J\u0010\u0010\u0003\u001a\u00020\u00002\u0006\u0010\u0003\u001a\u00020\u0004H\u0016J\b\u0010\u0005\u001a\u00020\u0006H\u0016J\"\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u00002\f\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u000f0\u0012H\u0086\bø\u0001\u0000J\b\u0010\u0013\u001a\u00020\u000fH\u0016J\u0018\u0010\u0014\u001a\u00020\u00002\u0006\u0010\u0014\u001a\u00020\u00042\u0006\u0010\f\u001a\u00020\rH\u0016J\b\u0010\u0007\u001a\u00020\u0004H\u0016J\u000e\u0010\u0015\u001a\u00020\u000f2\u0006\u0010\u0016\u001a\u00020\u0001R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000\u0082\u0002\u0007\n\u0005\b\u009920\u0001¨\u0006\u0018"}, d2 = {"Lokio/Timeout;", "", "()V", "deadlineNanoTime", "", "hasDeadline", "", "timeoutNanos", "clearDeadline", "clearTimeout", "deadline", "duration", "unit", "Ljava/util/concurrent/TimeUnit;", "intersectWith", "", "other", "block", "Lkotlin/Function0;", "throwIfReached", ProfilingTraceData.TRUNCATION_REASON_TIMEOUT, "waitUntilNotified", "monitor", "Companion", "okio"}, k = 1, mv = {1, 4, 0})
|
|
/* loaded from: classes3.dex */
|
|
public class Timeout {
|
|
|
|
/* renamed from: Companion, reason: from kotlin metadata */
|
|
public static final Companion INSTANCE = new Companion(null);
|
|
public static final Timeout NONE = new Timeout() { // from class: okio.Timeout$Companion$NONE$1
|
|
@Override // okio.Timeout
|
|
public void throwIfReached() {
|
|
}
|
|
|
|
@Override // okio.Timeout
|
|
public Timeout timeout(long timeout, TimeUnit unit) {
|
|
Intrinsics.checkNotNullParameter(unit, "unit");
|
|
return this;
|
|
}
|
|
|
|
@Override // okio.Timeout
|
|
public Timeout deadlineNanoTime(long deadlineNanoTime) {
|
|
return this;
|
|
}
|
|
};
|
|
private long deadlineNanoTime;
|
|
private boolean hasDeadline;
|
|
private long timeoutNanos;
|
|
|
|
public Timeout clearDeadline() {
|
|
this.hasDeadline = false;
|
|
return this;
|
|
}
|
|
|
|
public Timeout clearTimeout() {
|
|
this.timeoutNanos = 0L;
|
|
return this;
|
|
}
|
|
|
|
public Timeout deadlineNanoTime(long deadlineNanoTime) {
|
|
this.hasDeadline = true;
|
|
this.deadlineNanoTime = deadlineNanoTime;
|
|
return this;
|
|
}
|
|
|
|
/* renamed from: hasDeadline, reason: from getter */
|
|
public boolean getHasDeadline() {
|
|
return this.hasDeadline;
|
|
}
|
|
|
|
/* renamed from: timeoutNanos, reason: from getter */
|
|
public long getTimeoutNanos() {
|
|
return this.timeoutNanos;
|
|
}
|
|
|
|
public Timeout timeout(long timeout, TimeUnit unit) {
|
|
Intrinsics.checkNotNullParameter(unit, "unit");
|
|
if (!(timeout >= 0)) {
|
|
throw new IllegalArgumentException(("timeout < 0: " + timeout).toString());
|
|
}
|
|
this.timeoutNanos = unit.toNanos(timeout);
|
|
return this;
|
|
}
|
|
|
|
public long deadlineNanoTime() {
|
|
if (this.hasDeadline) {
|
|
return this.deadlineNanoTime;
|
|
}
|
|
throw new IllegalStateException("No deadline".toString());
|
|
}
|
|
|
|
public final Timeout deadline(long duration, TimeUnit unit) {
|
|
Intrinsics.checkNotNullParameter(unit, "unit");
|
|
if (!(duration > 0)) {
|
|
throw new IllegalArgumentException(("duration <= 0: " + duration).toString());
|
|
}
|
|
return deadlineNanoTime(System.nanoTime() + unit.toNanos(duration));
|
|
}
|
|
|
|
public void throwIfReached() throws IOException {
|
|
if (Thread.interrupted()) {
|
|
Thread.currentThread().interrupt();
|
|
throw new InterruptedIOException("interrupted");
|
|
}
|
|
if (this.hasDeadline && this.deadlineNanoTime - System.nanoTime() <= 0) {
|
|
throw new InterruptedIOException("deadline reached");
|
|
}
|
|
}
|
|
|
|
public final void waitUntilNotified(Object monitor) throws InterruptedIOException {
|
|
Intrinsics.checkNotNullParameter(monitor, "monitor");
|
|
try {
|
|
boolean hasDeadline = getHasDeadline();
|
|
long timeoutNanos = getTimeoutNanos();
|
|
long j = 0;
|
|
if (!hasDeadline && timeoutNanos == 0) {
|
|
monitor.wait();
|
|
return;
|
|
}
|
|
long nanoTime = System.nanoTime();
|
|
if (hasDeadline && timeoutNanos != 0) {
|
|
timeoutNanos = Math.min(timeoutNanos, deadlineNanoTime() - nanoTime);
|
|
} else if (hasDeadline) {
|
|
timeoutNanos = deadlineNanoTime() - nanoTime;
|
|
}
|
|
if (timeoutNanos > 0) {
|
|
long j2 = timeoutNanos / 1000000;
|
|
monitor.wait(j2, (int) (timeoutNanos - (1000000 * j2)));
|
|
j = System.nanoTime() - nanoTime;
|
|
}
|
|
if (j >= timeoutNanos) {
|
|
throw new InterruptedIOException(ProfilingTraceData.TRUNCATION_REASON_TIMEOUT);
|
|
}
|
|
} catch (InterruptedException unused) {
|
|
Thread.currentThread().interrupt();
|
|
throw new InterruptedIOException("interrupted");
|
|
}
|
|
}
|
|
|
|
public final void intersectWith(Timeout other, Function0<Unit> block) {
|
|
Intrinsics.checkNotNullParameter(other, "other");
|
|
Intrinsics.checkNotNullParameter(block, "block");
|
|
long timeoutNanos = getTimeoutNanos();
|
|
timeout(INSTANCE.minTimeout(other.getTimeoutNanos(), getTimeoutNanos()), TimeUnit.NANOSECONDS);
|
|
if (getHasDeadline()) {
|
|
long deadlineNanoTime = deadlineNanoTime();
|
|
if (other.getHasDeadline()) {
|
|
deadlineNanoTime(Math.min(deadlineNanoTime(), other.deadlineNanoTime()));
|
|
}
|
|
try {
|
|
block.invoke();
|
|
return;
|
|
} finally {
|
|
InlineMarker.finallyStart(1);
|
|
timeout(timeoutNanos, TimeUnit.NANOSECONDS);
|
|
if (other.getHasDeadline()) {
|
|
deadlineNanoTime(deadlineNanoTime);
|
|
}
|
|
InlineMarker.finallyEnd(1);
|
|
}
|
|
}
|
|
if (other.getHasDeadline()) {
|
|
deadlineNanoTime(other.deadlineNanoTime());
|
|
}
|
|
try {
|
|
block.invoke();
|
|
} finally {
|
|
InlineMarker.finallyStart(1);
|
|
timeout(timeoutNanos, TimeUnit.NANOSECONDS);
|
|
if (other.getHasDeadline()) {
|
|
clearDeadline();
|
|
}
|
|
InlineMarker.finallyEnd(1);
|
|
}
|
|
}
|
|
|
|
/* compiled from: Timeout.kt */
|
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0016\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\b\u001a\u00020\u0006R\u0010\u0010\u0003\u001a\u00020\u00048\u0006X\u0087\u0004¢\u0006\u0002\n\u0000¨\u0006\t"}, d2 = {"Lokio/Timeout$Companion;", "", "()V", "NONE", "Lokio/Timeout;", "minTimeout", "", "aNanos", "bNanos", "okio"}, k = 1, mv = {1, 4, 0})
|
|
/* loaded from: classes3.dex */
|
|
public static final class Companion {
|
|
public final long minTimeout(long aNanos, long bNanos) {
|
|
return (aNanos != 0 && (bNanos == 0 || aNanos < bNanos)) ? aNanos : bNanos;
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
}
|