89 lines
2.2 KiB
Java
89 lines
2.2 KiB
Java
package o;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InterruptedIOException;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class giY {
|
|
public static final giY NONE = new giY() { // from class: o.giY.1
|
|
@Override // o.giY
|
|
public final giY deadlineNanoTime(long j) {
|
|
return this;
|
|
}
|
|
|
|
@Override // o.giY
|
|
public final void throwIfReached() throws IOException {
|
|
}
|
|
|
|
@Override // o.giY
|
|
public final giY timeout(long j, TimeUnit timeUnit) {
|
|
return this;
|
|
}
|
|
};
|
|
private boolean anJ;
|
|
private long anK;
|
|
private long anL;
|
|
|
|
public giY timeout(long j, TimeUnit timeUnit) {
|
|
if (j < 0) {
|
|
throw new IllegalArgumentException("timeout < 0: ".concat(String.valueOf(j)));
|
|
}
|
|
if (timeUnit == null) {
|
|
throw new IllegalArgumentException("unit == null");
|
|
}
|
|
this.anL = timeUnit.toNanos(j);
|
|
return this;
|
|
}
|
|
|
|
public long deadlineNanoTime() {
|
|
if (this.anJ) {
|
|
return this.anK;
|
|
}
|
|
throw new IllegalStateException("No deadline");
|
|
}
|
|
|
|
public final giY deadline(long j, TimeUnit timeUnit) {
|
|
if (j <= 0) {
|
|
throw new IllegalArgumentException("duration <= 0: ".concat(String.valueOf(j)));
|
|
}
|
|
if (timeUnit == null) {
|
|
throw new IllegalArgumentException("unit == null");
|
|
}
|
|
return deadlineNanoTime(System.nanoTime() + timeUnit.toNanos(j));
|
|
}
|
|
|
|
public void throwIfReached() throws IOException {
|
|
if (Thread.interrupted()) {
|
|
throw new InterruptedIOException("thread interrupted");
|
|
}
|
|
if (this.anJ && this.anK - System.nanoTime() <= 0) {
|
|
throw new InterruptedIOException("deadline reached");
|
|
}
|
|
}
|
|
|
|
public long timeoutNanos() {
|
|
return this.anL;
|
|
}
|
|
|
|
public boolean hasDeadline() {
|
|
return this.anJ;
|
|
}
|
|
|
|
public giY deadlineNanoTime(long j) {
|
|
this.anJ = true;
|
|
this.anK = j;
|
|
return this;
|
|
}
|
|
|
|
public giY clearTimeout() {
|
|
this.anL = 0L;
|
|
return this;
|
|
}
|
|
|
|
public giY clearDeadline() {
|
|
this.anJ = false;
|
|
return this;
|
|
}
|
|
}
|