Ping.java
1.35 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
package com.squareup.okhttp.internal.framed;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public final class Ping
{
private final CountDownLatch latch = new CountDownLatch(1);
private long received = -1L;
private long sent = -1L;
final void cancel()
{
if ((this.received != -1L) || (this.sent == -1L)) {
throw new IllegalStateException();
}
this.received = (this.sent - 1L);
this.latch.countDown();
}
final void receive()
{
if ((this.received != -1L) || (this.sent == -1L)) {
throw new IllegalStateException();
}
this.received = System.nanoTime();
this.latch.countDown();
}
public final long roundTripTime()
throws InterruptedException
{
this.latch.await();
return this.received - this.sent;
}
public final long roundTripTime(long paramLong, TimeUnit paramTimeUnit)
throws InterruptedException
{
if (this.latch.await(paramLong, paramTimeUnit)) {
return this.received - this.sent;
}
return -2L;
}
final void send()
{
if (this.sent != -1L) {
throw new IllegalStateException();
}
this.sent = System.nanoTime();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/framed/Ping.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/