ProducerArbiter.smali
.class public final Lrx/internal/producers/ProducerArbiter;
.super Ljava/lang/Object;
.source "ProducerArbiter.java"
# interfaces
.implements Lrx/Producer;
# static fields
.field static final NULL_PRODUCER:Lrx/Producer;
# instance fields
.field currentProducer:Lrx/Producer;
.field emitting:Z
.field missedProduced:J
.field missedProducer:Lrx/Producer;
.field missedRequested:J
.field requested:J
# direct methods
.method static constructor <clinit>()V
.registers 1
.line 1
new-instance v0, Lrx/internal/producers/ProducerArbiter$1;
invoke-direct {v0}, Lrx/internal/producers/ProducerArbiter$1;-><init>()V
sput-object v0, Lrx/internal/producers/ProducerArbiter;->NULL_PRODUCER:Lrx/Producer;
return-void
.end method
.method public constructor <init>()V
.registers 1
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
# virtual methods
.method public emitLoop()V
.registers 14
.line 1
:cond_0
:goto_0
monitor-enter p0
.line 2
:try_start_1
iget-wide v0, p0, Lrx/internal/producers/ProducerArbiter;->missedRequested:J
.line 3
iget-wide v2, p0, Lrx/internal/producers/ProducerArbiter;->missedProduced:J
.line 4
iget-object v4, p0, Lrx/internal/producers/ProducerArbiter;->missedProducer:Lrx/Producer;
const-wide/16 v5, 0x0
cmp-long v7, v0, v5
if-nez v7, :cond_18
cmp-long v7, v2, v5
if-nez v7, :cond_18
if-nez v4, :cond_18
const/4 v0, 0x0
.line 5
iput-boolean v0, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
.line 6
monitor-exit p0
return-void
.line 7
:cond_18
iput-wide v5, p0, Lrx/internal/producers/ProducerArbiter;->missedRequested:J
.line 8
iput-wide v5, p0, Lrx/internal/producers/ProducerArbiter;->missedProduced:J
const/4 v7, 0x0
.line 9
iput-object v7, p0, Lrx/internal/producers/ProducerArbiter;->missedProducer:Lrx/Producer;
.line 10
monitor-exit p0
:try_end_20
.catchall {:try_start_1 .. :try_end_20} :catchall_63
.line 11
iget-wide v8, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
const-wide v10, 0x7fffffffffffffffL
cmp-long v12, v8, v10
if-eqz v12, :cond_48
add-long/2addr v8, v0
cmp-long v12, v8, v5
if-ltz v12, :cond_45
cmp-long v12, v8, v10
if-nez v12, :cond_35
goto :goto_45
:cond_35
sub-long/2addr v8, v2
cmp-long v2, v8, v5
if-ltz v2, :cond_3d
.line 12
iput-wide v8, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
goto :goto_48
.line 13
:cond_3d
new-instance v0, Ljava/lang/IllegalStateException;
const-string v1, "more produced than requested"
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.line 14
:cond_45
:goto_45
iput-wide v10, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
move-wide v8, v10
:cond_48
:goto_48
if-eqz v4, :cond_57
.line 15
sget-object v0, Lrx/internal/producers/ProducerArbiter;->NULL_PRODUCER:Lrx/Producer;
if-ne v4, v0, :cond_51
.line 16
iput-object v7, p0, Lrx/internal/producers/ProducerArbiter;->currentProducer:Lrx/Producer;
goto :goto_0
.line 17
:cond_51
iput-object v4, p0, Lrx/internal/producers/ProducerArbiter;->currentProducer:Lrx/Producer;
.line 18
invoke-interface {v4, v8, v9}, Lrx/Producer;->request(J)V
goto :goto_0
.line 19
:cond_57
iget-object v2, p0, Lrx/internal/producers/ProducerArbiter;->currentProducer:Lrx/Producer;
if-eqz v2, :cond_0
cmp-long v3, v0, v5
if-eqz v3, :cond_0
.line 20
invoke-interface {v2, v0, v1}, Lrx/Producer;->request(J)V
goto :goto_0
:catchall_63
move-exception v0
.line 21
:try_start_64
monitor-exit p0
:try_end_65
.catchall {:try_start_64 .. :try_end_65} :catchall_63
goto :goto_67
:goto_66
throw v0
:goto_67
goto :goto_66
.end method
.method public produced(J)V
.registers 10
const-wide/16 v0, 0x0
cmp-long v2, p1, v0
if-lez v2, :cond_42
.line 1
monitor-enter p0
.line 2
:try_start_7
iget-boolean v2, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
if-eqz v2, :cond_12
.line 3
iget-wide v0, p0, Lrx/internal/producers/ProducerArbiter;->missedProduced:J
add-long/2addr v0, p1
iput-wide v0, p0, Lrx/internal/producers/ProducerArbiter;->missedProduced:J
.line 4
monitor-exit p0
return-void
:cond_12
const/4 v2, 0x1
.line 5
iput-boolean v2, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
.line 6
monitor-exit p0
:try_end_16
.catchall {:try_start_7 .. :try_end_16} :catchall_3f
.line 7
:try_start_16
iget-wide v2, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
const-wide v4, 0x7fffffffffffffffL
cmp-long v6, v2, v4
if-eqz v6, :cond_31
sub-long/2addr v2, p1
cmp-long p1, v2, v0
if-ltz p1, :cond_29
.line 8
iput-wide v2, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
goto :goto_31
.line 9
:cond_29
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "more items arrived than were requested"
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
.line 10
:cond_31
:goto_31
invoke-virtual {p0}, Lrx/internal/producers/ProducerArbiter;->emitLoop()V
:try_end_34
.catchall {:try_start_16 .. :try_end_34} :catchall_35
return-void
:catchall_35
move-exception p1
.line 11
monitor-enter p0
const/4 p2, 0x0
.line 12
:try_start_38
iput-boolean p2, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
.line 13
monitor-exit p0
:try_end_3b
.catchall {:try_start_38 .. :try_end_3b} :catchall_3c
throw p1
:catchall_3c
move-exception p1
:try_start_3d
monitor-exit p0
:try_end_3e
.catchall {:try_start_3d .. :try_end_3e} :catchall_3c
throw p1
:catchall_3f
move-exception p1
.line 14
:try_start_40
monitor-exit p0
:try_end_41
.catchall {:try_start_40 .. :try_end_41} :catchall_3f
throw p1
.line 15
:cond_42
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string p2, "n > 0 required"
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method public request(J)V
.registers 8
const-wide/16 v0, 0x0
cmp-long v2, p1, v0
if-ltz v2, :cond_41
cmp-long v2, p1, v0
if-nez v2, :cond_b
return-void
.line 1
:cond_b
monitor-enter p0
.line 2
:try_start_c
iget-boolean v2, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
if-eqz v2, :cond_17
.line 3
iget-wide v0, p0, Lrx/internal/producers/ProducerArbiter;->missedRequested:J
add-long/2addr v0, p1
iput-wide v0, p0, Lrx/internal/producers/ProducerArbiter;->missedRequested:J
.line 4
monitor-exit p0
return-void
:cond_17
const/4 v2, 0x1
.line 5
iput-boolean v2, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
.line 6
monitor-exit p0
:try_end_1b
.catchall {:try_start_c .. :try_end_1b} :catchall_3e
.line 7
:try_start_1b
iget-wide v2, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
add-long/2addr v2, p1
cmp-long v4, v2, v0
if-gez v4, :cond_27
const-wide v2, 0x7fffffffffffffffL
.line 8
:cond_27
iput-wide v2, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
.line 9
iget-object v0, p0, Lrx/internal/producers/ProducerArbiter;->currentProducer:Lrx/Producer;
if-eqz v0, :cond_30
.line 10
invoke-interface {v0, p1, p2}, Lrx/Producer;->request(J)V
.line 11
:cond_30
invoke-virtual {p0}, Lrx/internal/producers/ProducerArbiter;->emitLoop()V
:try_end_33
.catchall {:try_start_1b .. :try_end_33} :catchall_34
return-void
:catchall_34
move-exception p1
.line 12
monitor-enter p0
const/4 p2, 0x0
.line 13
:try_start_37
iput-boolean p2, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
.line 14
monitor-exit p0
:try_end_3a
.catchall {:try_start_37 .. :try_end_3a} :catchall_3b
throw p1
:catchall_3b
move-exception p1
:try_start_3c
monitor-exit p0
:try_end_3d
.catchall {:try_start_3c .. :try_end_3d} :catchall_3b
throw p1
:catchall_3e
move-exception p1
.line 15
:try_start_3f
monitor-exit p0
:try_end_40
.catchall {:try_start_3f .. :try_end_40} :catchall_3e
throw p1
.line 16
:cond_41
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string p2, "n >= 0 required"
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method public setProducer(Lrx/Producer;)V
.registers 4
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-boolean v0, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
if-eqz v0, :cond_d
if-nez p1, :cond_9
.line 3
sget-object p1, Lrx/internal/producers/ProducerArbiter;->NULL_PRODUCER:Lrx/Producer;
:cond_9
iput-object p1, p0, Lrx/internal/producers/ProducerArbiter;->missedProducer:Lrx/Producer;
.line 4
monitor-exit p0
return-void
:cond_d
const/4 v0, 0x1
.line 5
iput-boolean v0, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
.line 6
monitor-exit p0
:try_end_11
.catchall {:try_start_1 .. :try_end_11} :catchall_28
.line 7
:try_start_11
iput-object p1, p0, Lrx/internal/producers/ProducerArbiter;->currentProducer:Lrx/Producer;
if-eqz p1, :cond_1a
.line 8
iget-wide v0, p0, Lrx/internal/producers/ProducerArbiter;->requested:J
invoke-interface {p1, v0, v1}, Lrx/Producer;->request(J)V
.line 9
:cond_1a
invoke-virtual {p0}, Lrx/internal/producers/ProducerArbiter;->emitLoop()V
:try_end_1d
.catchall {:try_start_11 .. :try_end_1d} :catchall_1e
return-void
:catchall_1e
move-exception p1
.line 10
monitor-enter p0
const/4 v0, 0x0
.line 11
:try_start_21
iput-boolean v0, p0, Lrx/internal/producers/ProducerArbiter;->emitting:Z
.line 12
monitor-exit p0
:try_end_24
.catchall {:try_start_21 .. :try_end_24} :catchall_25
throw p1
:catchall_25
move-exception p1
:try_start_26
monitor-exit p0
:try_end_27
.catchall {:try_start_26 .. :try_end_27} :catchall_25
throw p1
:catchall_28
move-exception p1
.line 13
:try_start_29
monitor-exit p0
:try_end_2a
.catchall {:try_start_29 .. :try_end_2a} :catchall_28
throw p1
.end method