Timeout.java
2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package okio;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.concurrent.TimeUnit;
public class Timeout
{
public static final Timeout NONE = new Timeout()
{
public final Timeout deadlineNanoTime(long paramAnonymousLong)
{
return this;
}
public final void throwIfReached()
throws IOException
{}
public final Timeout timeout(long paramAnonymousLong, TimeUnit paramAnonymousTimeUnit)
{
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 final Timeout deadline(long paramLong, TimeUnit paramTimeUnit)
{
if (paramLong <= 0L) {
throw new IllegalArgumentException("duration <= 0: " + paramLong);
}
if (paramTimeUnit == null) {
throw new IllegalArgumentException("unit == null");
}
return deadlineNanoTime(System.nanoTime() + paramTimeUnit.toNanos(paramLong));
}
public long deadlineNanoTime()
{
if (!this.hasDeadline) {
throw new IllegalStateException("No deadline");
}
return this.deadlineNanoTime;
}
public Timeout deadlineNanoTime(long paramLong)
{
this.hasDeadline = true;
this.deadlineNanoTime = paramLong;
return this;
}
public boolean hasDeadline()
{
return this.hasDeadline;
}
public void throwIfReached()
throws IOException
{
if (Thread.interrupted()) {
throw new InterruptedIOException("thread interrupted");
}
if ((this.hasDeadline) && (this.deadlineNanoTime - System.nanoTime() <= 0L)) {
throw new InterruptedIOException("deadline reached");
}
}
public Timeout timeout(long paramLong, TimeUnit paramTimeUnit)
{
if (paramLong < 0L) {
throw new IllegalArgumentException("timeout < 0: " + paramLong);
}
if (paramTimeUnit == null) {
throw new IllegalArgumentException("unit == null");
}
this.timeoutNanos = paramTimeUnit.toNanos(paramLong);
return this;
}
public long timeoutNanos()
{
return this.timeoutNanos;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/okio/Timeout.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/