172 lines
5.2 KiB
Java
172 lines
5.2 KiB
Java
|
package o;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.io.InterruptedIOException;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
|
||
|
/* renamed from: o.giB, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes.dex */
|
||
|
public class C15139giB {
|
||
|
public static final RVV Companion = new RVV(0);
|
||
|
public static final C15139giB NONE = new IeS();
|
||
|
private long deadlineNanoTime;
|
||
|
private boolean hasDeadline;
|
||
|
private long timeoutNanos;
|
||
|
|
||
|
public C15139giB timeout(long j, TimeUnit timeUnit) {
|
||
|
C14957gcv.e(timeUnit, "");
|
||
|
if (j < 0) {
|
||
|
throw new IllegalArgumentException("timeout < 0: ".concat(String.valueOf(j)).toString());
|
||
|
}
|
||
|
this.timeoutNanos = timeUnit.toNanos(j);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public long deadlineNanoTime() {
|
||
|
if (this.hasDeadline) {
|
||
|
return this.deadlineNanoTime;
|
||
|
}
|
||
|
throw new IllegalStateException("No deadline".toString());
|
||
|
}
|
||
|
|
||
|
public final C15139giB deadline(long j, TimeUnit timeUnit) {
|
||
|
C14957gcv.e(timeUnit, "");
|
||
|
if (j <= 0) {
|
||
|
throw new IllegalArgumentException("duration <= 0: ".concat(String.valueOf(j)).toString());
|
||
|
}
|
||
|
return deadlineNanoTime(System.nanoTime() + timeUnit.toNanos(j));
|
||
|
}
|
||
|
|
||
|
public void throwIfReached() throws IOException {
|
||
|
if (Thread.currentThread().isInterrupted()) {
|
||
|
throw new InterruptedIOException("interrupted");
|
||
|
}
|
||
|
if (this.hasDeadline && this.deadlineNanoTime - System.nanoTime() <= 0) {
|
||
|
throw new InterruptedIOException("deadline reached");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final void waitUntilNotified(Object obj) throws InterruptedIOException {
|
||
|
C14957gcv.e(obj, "");
|
||
|
try {
|
||
|
boolean hasDeadline = hasDeadline();
|
||
|
long timeoutNanos = timeoutNanos();
|
||
|
long j = 0;
|
||
|
if (!hasDeadline && timeoutNanos == 0) {
|
||
|
obj.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;
|
||
|
obj.wait(j2, (int) (timeoutNanos - (1000000 * j2)));
|
||
|
j = System.nanoTime() - nanoTime;
|
||
|
}
|
||
|
if (j >= timeoutNanos) {
|
||
|
throw new InterruptedIOException("timeout");
|
||
|
}
|
||
|
} catch (InterruptedException unused) {
|
||
|
Thread.currentThread().interrupt();
|
||
|
throw new InterruptedIOException("interrupted");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final <T> T intersectWith(C15139giB c15139giB, InterfaceC14890gbN<? extends T> interfaceC14890gbN) {
|
||
|
C14957gcv.e(c15139giB, "");
|
||
|
C14957gcv.e(interfaceC14890gbN, "");
|
||
|
long timeoutNanos = timeoutNanos();
|
||
|
timeout(RVV.d(c15139giB.timeoutNanos(), timeoutNanos()), TimeUnit.NANOSECONDS);
|
||
|
if (hasDeadline()) {
|
||
|
long deadlineNanoTime = deadlineNanoTime();
|
||
|
if (c15139giB.hasDeadline()) {
|
||
|
deadlineNanoTime(Math.min(deadlineNanoTime(), c15139giB.deadlineNanoTime()));
|
||
|
}
|
||
|
try {
|
||
|
return interfaceC14890gbN.invoke();
|
||
|
} finally {
|
||
|
timeout(timeoutNanos, TimeUnit.NANOSECONDS);
|
||
|
if (c15139giB.hasDeadline()) {
|
||
|
deadlineNanoTime(deadlineNanoTime);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (c15139giB.hasDeadline()) {
|
||
|
deadlineNanoTime(c15139giB.deadlineNanoTime());
|
||
|
}
|
||
|
try {
|
||
|
return interfaceC14890gbN.invoke();
|
||
|
} finally {
|
||
|
timeout(timeoutNanos, TimeUnit.NANOSECONDS);
|
||
|
if (c15139giB.hasDeadline()) {
|
||
|
clearDeadline();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* renamed from: o.giB$RVV */
|
||
|
/* loaded from: classes.dex */
|
||
|
public static final class RVV {
|
||
|
public static long d(long j, long j2) {
|
||
|
return (j == 0 || (j2 != 0 && j >= j2)) ? j2 : j;
|
||
|
}
|
||
|
|
||
|
private RVV() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ RVV(byte b) {
|
||
|
this();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* renamed from: o.giB$IeS */
|
||
|
/* loaded from: classes.dex */
|
||
|
public static final class IeS extends C15139giB {
|
||
|
@Override // o.C15139giB
|
||
|
public final void throwIfReached() {
|
||
|
}
|
||
|
|
||
|
IeS() {
|
||
|
}
|
||
|
|
||
|
@Override // o.C15139giB
|
||
|
public final C15139giB timeout(long j, TimeUnit timeUnit) {
|
||
|
C14957gcv.e(timeUnit, "");
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // o.C15139giB
|
||
|
public final C15139giB deadlineNanoTime(long j) {
|
||
|
return this;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public long timeoutNanos() {
|
||
|
return this.timeoutNanos;
|
||
|
}
|
||
|
|
||
|
public boolean hasDeadline() {
|
||
|
return this.hasDeadline;
|
||
|
}
|
||
|
|
||
|
public C15139giB deadlineNanoTime(long j) {
|
||
|
this.hasDeadline = true;
|
||
|
this.deadlineNanoTime = j;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public C15139giB clearTimeout() {
|
||
|
this.timeoutNanos = 0L;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public C15139giB clearDeadline() {
|
||
|
this.hasDeadline = false;
|
||
|
return this;
|
||
|
}
|
||
|
}
|