Throttler.smali
.class public final Lokio/Throttler;
.super Ljava/lang/Object;
.source "Throttler.kt"
# annotations
.annotation runtime Lkotlin/Metadata;
bv = {
0x1,
0x0,
0x3
}
d1 = {
"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0008\u0002\n\u0002\u0010\t\n\u0002\u0008\u0008\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0007\u0018\u00002\u00020\u0001B\u0007\u0008\u0016\u00a2\u0006\u0002\u0010\u0002B\u000f\u0008\u0000\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u00a2\u0006\u0002\u0010\u0005J\u001d\u0010\t\u001a\u00020\u00042\u0006\u0010\n\u001a\u00020\u00042\u0006\u0010\u000b\u001a\u00020\u0004H\u0000\u00a2\u0006\u0002\u0008\u000cJ$\u0010\u0006\u001a\u00020\r2\u0006\u0010\u0006\u001a\u00020\u00042\u0008\u0008\u0002\u0010\u0008\u001a\u00020\u00042\u0008\u0008\u0002\u0010\u0007\u001a\u00020\u0004H\u0007J\u000e\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u000e\u001a\u00020\u000fJ\u000e\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0010\u001a\u00020\u0011J\u0015\u0010\u0012\u001a\u00020\u00042\u0006\u0010\u000b\u001a\u00020\u0004H\u0000\u00a2\u0006\u0002\u0008\u0013J\u0010\u0010\u0014\u001a\u00020\r2\u0006\u0010\u0015\u001a\u00020\u0004H\u0002J\u000c\u0010\u0016\u001a\u00020\u0004*\u00020\u0004H\u0002J\u000c\u0010\u0017\u001a\u00020\u0004*\u00020\u0004H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0008\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000\u00a8\u0006\u0018"
}
d2 = {
"Lokio/Throttler;",
"",
"()V",
"allocatedUntil",
"",
"(J)V",
"bytesPerSecond",
"maxByteCount",
"waitByteCount",
"byteCountOrWaitNanos",
"now",
"byteCount",
"byteCountOrWaitNanos$okio",
"",
"sink",
"Lokio/Sink;",
"source",
"Lokio/Source;",
"take",
"take$okio",
"waitNanos",
"nanosToWait",
"bytesToNanos",
"nanosToBytes",
"okio"
}
k = 0x1
mv = {
0x1,
0x1,
0x10
}
.end annotation
# instance fields
.field public allocatedUntil:J
.field public bytesPerSecond:J
.field public maxByteCount:J
.field public waitByteCount:J
# direct methods
.method static constructor <clinit>()V
.registers 1
return-void
.end method
.method public constructor <init>()V
.registers 3
invoke-static {}, Ljava/lang/System;->nanoTime()J
move-result-wide v0
invoke-direct {p0, v0, v1}, Lokio/Throttler;-><init>(J)V
return-void
.end method
.method public constructor <init>(J)V
.registers 3
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-wide p1, p0, Lokio/Throttler;->allocatedUntil:J
const-wide/16 p1, 0x2000
iput-wide p1, p0, Lokio/Throttler;->waitByteCount:J
const-wide/32 p1, 0x40000
iput-wide p1, p0, Lokio/Throttler;->maxByteCount:J
return-void
.end method
.method public static synthetic bytesPerSecond$default(Lokio/Throttler;JJJILjava/lang/Object;)V
.registers 16
and-int/lit8 p8, p7, 0x2
if-eqz p8, :cond_6
iget-wide p3, p0, Lokio/Throttler;->waitByteCount:J
:cond_6
move-wide v3, p3
and-int/lit8 p3, p7, 0x4
if-eqz p3, :cond_d
iget-wide p5, p0, Lokio/Throttler;->maxByteCount:J
:cond_d
move-wide v5, p5
move-object v0, p0
move-wide v1, p1
invoke-virtual/range {v0 .. v6}, Lokio/Throttler;->bytesPerSecond(JJJ)V
return-void
.end method
.method private final bytesToNanos(J)J
.registers 5
const-wide/32 v0, 0x3b9aca00
mul-long p1, p1, v0
iget-wide v0, p0, Lokio/Throttler;->bytesPerSecond:J
div-long/2addr p1, v0
return-wide p1
.end method
.method private final nanosToBytes(J)J
.registers 5
iget-wide v0, p0, Lokio/Throttler;->bytesPerSecond:J
mul-long p1, p1, v0
const-wide/32 v0, 0x3b9aca00
div-long/2addr p1, v0
return-wide p1
.end method
.method private final waitNanos(J)V
.registers 7
const-wide/32 v0, 0xf4240
div-long v2, p1, v0
mul-long v0, v0, v2
sub-long/2addr p1, v0
long-to-int p2, p1
invoke-virtual {p0, v2, v3, p2}, Ljava/lang/Object;->wait(JI)V
return-void
.end method
# virtual methods
.method public final byteCountOrWaitNanos$okio(JJ)J
.registers 14
iget-wide v0, p0, Lokio/Throttler;->bytesPerSecond:J
const-wide/16 v2, 0x0
cmp-long v4, v0, v2
if-nez v4, :cond_9
return-wide p3
:cond_9
iget-wide v0, p0, Lokio/Throttler;->allocatedUntil:J
sub-long/2addr v0, p1
invoke-static {v0, v1, v2, v3}, Ljava/lang/Math;->max(JJ)J
move-result-wide v0
iget-wide v4, p0, Lokio/Throttler;->maxByteCount:J
invoke-direct {p0, v0, v1}, Lokio/Throttler;->nanosToBytes(J)J
move-result-wide v6
sub-long/2addr v4, v6
cmp-long v6, v4, p3
if-ltz v6, :cond_24
add-long/2addr p1, v0
invoke-direct {p0, p3, p4}, Lokio/Throttler;->bytesToNanos(J)J
move-result-wide v0
add-long/2addr p1, v0
iput-wide p1, p0, Lokio/Throttler;->allocatedUntil:J
return-wide p3
:cond_24
iget-wide v6, p0, Lokio/Throttler;->waitByteCount:J
cmp-long v8, v4, v6
if-ltz v8, :cond_34
iget-wide p3, p0, Lokio/Throttler;->maxByteCount:J
invoke-direct {p0, p3, p4}, Lokio/Throttler;->bytesToNanos(J)J
move-result-wide p3
add-long/2addr p1, p3
iput-wide p1, p0, Lokio/Throttler;->allocatedUntil:J
return-wide v4
:cond_34
invoke-static {v6, v7, p3, p4}, Ljava/lang/Math;->min(JJ)J
move-result-wide p3
iget-wide v4, p0, Lokio/Throttler;->maxByteCount:J
sub-long v4, p3, v4
invoke-direct {p0, v4, v5}, Lokio/Throttler;->bytesToNanos(J)J
move-result-wide v4
add-long/2addr v0, v4
cmp-long v4, v0, v2
if-nez v4, :cond_4f
iget-wide v0, p0, Lokio/Throttler;->maxByteCount:J
invoke-direct {p0, v0, v1}, Lokio/Throttler;->bytesToNanos(J)J
move-result-wide v0
add-long/2addr p1, v0
iput-wide p1, p0, Lokio/Throttler;->allocatedUntil:J
return-wide p3
:cond_4f
neg-long p1, v0
return-wide p1
.end method
.method public final bytesPerSecond(J)V
.registers 12
.annotation build Lkotlin/jvm/JvmOverloads;
.end annotation
const-wide/16 v3, 0x0
const-wide/16 v5, 0x0
const/4 v7, 0x6
const/4 v8, 0x0
move-object v0, p0
move-wide v1, p1
invoke-static/range {v0 .. v8}, Lokio/Throttler;->bytesPerSecond$default(Lokio/Throttler;JJJILjava/lang/Object;)V
return-void
.end method
.method public final bytesPerSecond(JJ)V
.registers 14
.annotation build Lkotlin/jvm/JvmOverloads;
.end annotation
const-wide/16 v5, 0x0
const/4 v7, 0x4
const/4 v8, 0x0
move-object v0, p0
move-wide v1, p1
move-wide v3, p3
invoke-static/range {v0 .. v8}, Lokio/Throttler;->bytesPerSecond$default(Lokio/Throttler;JJJILjava/lang/Object;)V
return-void
.end method
.method public final bytesPerSecond(JJJ)V
.registers 12
.annotation build Lkotlin/jvm/JvmOverloads;
.end annotation
monitor-enter p0
const-wide/16 v0, 0x0
const/4 v2, 0x1
const/4 v3, 0x0
cmp-long v4, p1, v0
if-ltz v4, :cond_b
const/4 v4, 0x1
goto :goto_c
:cond_b
const/4 v4, 0x0
:goto_c
if-eqz v4, :cond_44
cmp-long v4, p3, v0
if-lez v4, :cond_14
const/4 v0, 0x1
goto :goto_15
:cond_14
const/4 v0, 0x0
:goto_15
if-eqz v0, :cond_38
cmp-long v0, p5, p3
if-ltz v0, :cond_1c
goto :goto_1d
:cond_1c
const/4 v2, 0x0
:goto_1d
if-eqz v2, :cond_2c
:try_start_1f
iput-wide p1, p0, Lokio/Throttler;->bytesPerSecond:J
iput-wide p3, p0, Lokio/Throttler;->waitByteCount:J
iput-wide p5, p0, Lokio/Throttler;->maxByteCount:J
invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V
sget-object p1, Lkotlin/Unit;->INSTANCE:Lkotlin/Unit;
:try_end_2a
.catchall {:try_start_1f .. :try_end_2a} :catchall_50
monitor-exit p0
return-void
:cond_2c
:try_start_2c
const-string p1, "Failed requirement."
new-instance p2, Ljava/lang/IllegalArgumentException;
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p2
:cond_38
const-string p1, "Failed requirement."
new-instance p2, Ljava/lang/IllegalArgumentException;
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p2
:cond_44
const-string p1, "Failed requirement."
new-instance p2, Ljava/lang/IllegalArgumentException;
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p2
:try_end_50
.catchall {:try_start_2c .. :try_end_50} :catchall_50
:catchall_50
move-exception p1
monitor-exit p0
throw p1
.end method
.method public final sink(Lokio/Sink;)Lokio/Sink;
.registers 3
new-instance v0, Lokio/Throttler$sink$1;
invoke-direct {v0, p0, p1, p1}, Lokio/Throttler$sink$1;-><init>(Lokio/Throttler;Lokio/Sink;Lokio/Sink;)V
return-object v0
.end method
.method public final source(Lokio/Source;)Lokio/Source;
.registers 3
new-instance v0, Lokio/Throttler$source$1;
invoke-direct {v0, p0, p1, p1}, Lokio/Throttler$source$1;-><init>(Lokio/Throttler;Lokio/Source;Lokio/Source;)V
return-object v0
.end method
.method public final take$okio(J)J
.registers 8
const-wide/16 v0, 0x0
cmp-long v2, p1, v0
if-lez v2, :cond_8
const/4 v2, 0x1
goto :goto_9
:cond_8
const/4 v2, 0x0
:goto_9
if-eqz v2, :cond_22
monitor-enter p0
:goto_c
:try_start_c
invoke-static {}, Ljava/lang/System;->nanoTime()J
move-result-wide v2
invoke-virtual {p0, v2, v3, p1, p2}, Lokio/Throttler;->byteCountOrWaitNanos$okio(JJ)J
move-result-wide v2
:try_end_14
.catchall {:try_start_c .. :try_end_14} :catchall_1f
cmp-long v4, v2, v0
if-ltz v4, :cond_1a
monitor-exit p0
return-wide v2
:cond_1a
neg-long v2, v2
:try_start_1b
invoke-direct {p0, v2, v3}, Lokio/Throttler;->waitNanos(J)V
:try_end_1e
.catchall {:try_start_1b .. :try_end_1e} :catchall_1f
goto :goto_c
:catchall_1f
move-exception p1
monitor-exit p0
throw p1
:cond_22
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string p2, "Failed requirement."
invoke-virtual {p2}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p2
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
goto :goto_2f
:goto_2e
throw p1
:goto_2f
goto :goto_2e
.end method