123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- .class public Lokio/Timeout;
- .super Ljava/lang/Object;
- .source ""
- # static fields
- .field public static final NONE:Lokio/Timeout;
- # instance fields
- .field private deadlineNanoTime:J
- .field private hasDeadline:Z
- .field private timeoutNanos:J
- # direct methods
- .method static constructor <clinit>()V
- .locals 1
- new-instance v0, Lokio/Timeout$1;
- invoke-direct {v0}, Lokio/Timeout$1;-><init>()V
- sput-object v0, Lokio/Timeout;->NONE:Lokio/Timeout;
- return-void
- .end method
- .method public constructor <init>()V
- .locals 0
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
- .end method
- # virtual methods
- .method public clearDeadline()Lokio/Timeout;
- .locals 1
- const/4 v0, 0x0
- iput-boolean v0, p0, Lokio/Timeout;->hasDeadline:Z
- return-object p0
- .end method
- .method public clearTimeout()Lokio/Timeout;
- .locals 2
- const-wide/16 v0, 0x0
- iput-wide v0, p0, Lokio/Timeout;->timeoutNanos:J
- return-object p0
- .end method
- .method public final deadline(JLjava/util/concurrent/TimeUnit;)Lokio/Timeout;
- .locals 3
- const-wide/16 v0, 0x0
- cmp-long v2, p1, v0
- if-lez v2, :cond_1
- if-eqz p3, :cond_0
- invoke-static {}, Ljava/lang/System;->nanoTime()J
- move-result-wide v0
- invoke-virtual {p3, p1, p2}, Ljava/util/concurrent/TimeUnit;->toNanos(J)J
- move-result-wide p1
- add-long/2addr v0, p1
- invoke-virtual {p0, v0, v1}, Lokio/Timeout;->deadlineNanoTime(J)Lokio/Timeout;
- move-result-object p1
- return-object p1
- :cond_0
- new-instance p1, Ljava/lang/IllegalArgumentException;
- const-string p2, "unit == null"
- invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw p1
- :cond_1
- new-instance p3, Ljava/lang/IllegalArgumentException;
- new-instance v0, Ljava/lang/StringBuilder;
- invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
- const-string v1, "duration <= 0: "
- invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v0, p1, p2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
- invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p1
- invoke-direct {p3, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw p3
- .end method
- .method public deadlineNanoTime()J
- .locals 2
- iget-boolean v0, p0, Lokio/Timeout;->hasDeadline:Z
- if-eqz v0, :cond_0
- iget-wide v0, p0, Lokio/Timeout;->deadlineNanoTime:J
- return-wide v0
- :cond_0
- new-instance v0, Ljava/lang/IllegalStateException;
- const-string v1, "No deadline"
- invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
- throw v0
- .end method
- .method public deadlineNanoTime(J)Lokio/Timeout;
- .locals 1
- const/4 v0, 0x1
- iput-boolean v0, p0, Lokio/Timeout;->hasDeadline:Z
- iput-wide p1, p0, Lokio/Timeout;->deadlineNanoTime:J
- return-object p0
- .end method
- .method public hasDeadline()Z
- .locals 1
- iget-boolean v0, p0, Lokio/Timeout;->hasDeadline:Z
- return v0
- .end method
- .method public throwIfReached()V
- .locals 5
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- invoke-static {}, Ljava/lang/Thread;->interrupted()Z
- move-result v0
- if-nez v0, :cond_2
- iget-boolean v0, p0, Lokio/Timeout;->hasDeadline:Z
- if-eqz v0, :cond_1
- iget-wide v0, p0, Lokio/Timeout;->deadlineNanoTime:J
- invoke-static {}, Ljava/lang/System;->nanoTime()J
- move-result-wide v2
- sub-long/2addr v0, v2
- const-wide/16 v2, 0x0
- cmp-long v4, v0, v2
- if-lez v4, :cond_0
- goto :goto_0
- :cond_0
- new-instance v0, Ljava/io/InterruptedIOException;
- const-string v1, "deadline reached"
- invoke-direct {v0, v1}, Ljava/io/InterruptedIOException;-><init>(Ljava/lang/String;)V
- throw v0
- :cond_1
- :goto_0
- return-void
- :cond_2
- new-instance v0, Ljava/io/InterruptedIOException;
- const-string v1, "thread interrupted"
- invoke-direct {v0, v1}, Ljava/io/InterruptedIOException;-><init>(Ljava/lang/String;)V
- throw v0
- .end method
- .method public timeout(JLjava/util/concurrent/TimeUnit;)Lokio/Timeout;
- .locals 3
- const-wide/16 v0, 0x0
- cmp-long v2, p1, v0
- if-ltz v2, :cond_1
- if-eqz p3, :cond_0
- invoke-virtual {p3, p1, p2}, Ljava/util/concurrent/TimeUnit;->toNanos(J)J
- move-result-wide p1
- iput-wide p1, p0, Lokio/Timeout;->timeoutNanos:J
- return-object p0
- :cond_0
- new-instance p1, Ljava/lang/IllegalArgumentException;
- const-string p2, "unit == null"
- invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw p1
- :cond_1
- new-instance p3, Ljava/lang/IllegalArgumentException;
- new-instance v0, Ljava/lang/StringBuilder;
- invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
- const-string v1, "timeout < 0: "
- invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v0, p1, p2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
- invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p1
- invoke-direct {p3, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw p3
- .end method
- .method public timeoutNanos()J
- .locals 2
- iget-wide v0, p0, Lokio/Timeout;->timeoutNanos:J
- return-wide v0
- .end method
- .method public final waitUntilNotified(Ljava/lang/Object;)V
- .locals 9
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/InterruptedIOException;
- }
- .end annotation
- :try_start_0
- invoke-virtual {p0}, Lokio/Timeout;->hasDeadline()Z
- move-result v0
- invoke-virtual {p0}, Lokio/Timeout;->timeoutNanos()J
- move-result-wide v1
- const-wide/16 v3, 0x0
- if-nez v0, :cond_0
- cmp-long v5, v1, v3
- if-nez v5, :cond_0
- invoke-virtual {p1}, Ljava/lang/Object;->wait()V
- return-void
- :cond_0
- invoke-static {}, Ljava/lang/System;->nanoTime()J
- move-result-wide v5
- if-eqz v0, :cond_1
- cmp-long v7, v1, v3
- if-eqz v7, :cond_1
- invoke-virtual {p0}, Lokio/Timeout;->deadlineNanoTime()J
- move-result-wide v7
- sub-long/2addr v7, v5
- invoke-static {v1, v2, v7, v8}, Ljava/lang/Math;->min(JJ)J
- move-result-wide v1
- goto :goto_0
- :cond_1
- if-eqz v0, :cond_2
- invoke-virtual {p0}, Lokio/Timeout;->deadlineNanoTime()J
- move-result-wide v0
- sub-long/2addr v0, v5
- move-wide v1, v0
- :cond_2
- :goto_0
- cmp-long v0, v1, v3
- if-lez v0, :cond_3
- const-wide/32 v3, 0xf4240
- div-long v7, v1, v3
- :try_end_0
- .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0
- invoke-static {v7, v8}, Ljava/lang/Long;->signum(J)I
- mul-long v3, v3, v7
- sub-long v3, v1, v3
- long-to-int v0, v3
- :try_start_1
- invoke-virtual {p1, v7, v8, v0}, Ljava/lang/Object;->wait(JI)V
- invoke-static {}, Ljava/lang/System;->nanoTime()J
- move-result-wide v3
- sub-long/2addr v3, v5
- :cond_3
- cmp-long p1, v3, v1
- if-gez p1, :cond_4
- return-void
- :cond_4
- new-instance p1, Ljava/io/InterruptedIOException;
- const-string v0, "timeout"
- invoke-direct {p1, v0}, Ljava/io/InterruptedIOException;-><init>(Ljava/lang/String;)V
- throw p1
- :try_end_1
- .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_0
- :catch_0
- new-instance p1, Ljava/io/InterruptedIOException;
- const-string v0, "interrupted"
- invoke-direct {p1, v0}, Ljava/io/InterruptedIOException;-><init>(Ljava/lang/String;)V
- throw p1
- .end method
|