ProducerObserverArbiter.smali
.class public final Lrx/internal/producers/ProducerObserverArbiter;
.super Ljava/lang/Object;
.source "ProducerObserverArbiter.java"
# interfaces
.implements Lrx/Producer;
.implements Lrx/Observer;
# annotations
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">",
"Ljava/lang/Object;",
"Lrx/Producer;",
"Lrx/Observer<",
"TT;>;"
}
.end annotation
# static fields
.field static final NULL_PRODUCER:Lrx/Producer;
# instance fields
.field final child:Lrx/Subscriber;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lrx/Subscriber<",
"-TT;>;"
}
.end annotation
.end field
.field currentProducer:Lrx/Producer;
.field emitting:Z
.field volatile hasError:Z
.field missedProducer:Lrx/Producer;
.field missedRequested:J
.field missedTerminal:Ljava/lang/Object;
.field queue:Ljava/util/List;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/List<",
"TT;>;"
}
.end annotation
.end field
.field requested:J
# direct methods
.method static constructor <clinit>()V
.registers 1
.line 1
new-instance v0, Lrx/internal/producers/ProducerObserverArbiter$1;
invoke-direct {v0}, Lrx/internal/producers/ProducerObserverArbiter$1;-><init>()V
sput-object v0, Lrx/internal/producers/ProducerObserverArbiter;->NULL_PRODUCER:Lrx/Producer;
return-void
.end method
.method public constructor <init>(Lrx/Subscriber;)V
.registers 2
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lrx/Subscriber<",
"-TT;>;)V"
}
.end annotation
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 2
iput-object p1, p0, Lrx/internal/producers/ProducerObserverArbiter;->child:Lrx/Subscriber;
return-void
.end method
# virtual methods
.method emitLoop()V
.registers 19
move-object/from16 v1, p0
.line 1
iget-object v2, v1, Lrx/internal/producers/ProducerObserverArbiter;->child:Lrx/Subscriber;
const/4 v0, 0x0
const-wide/16 v3, 0x0
move-object v7, v0
move-wide v5, v3
.line 2
:cond_9
:goto_9
monitor-enter p0
.line 3
:try_start_a
iget-wide v8, v1, Lrx/internal/producers/ProducerObserverArbiter;->missedRequested:J
.line 4
iget-object v10, v1, Lrx/internal/producers/ProducerObserverArbiter;->missedProducer:Lrx/Producer;
.line 5
iget-object v11, v1, Lrx/internal/producers/ProducerObserverArbiter;->missedTerminal:Ljava/lang/Object;
.line 6
iget-object v12, v1, Lrx/internal/producers/ProducerObserverArbiter;->queue:Ljava/util/List;
const/4 v13, 0x1
const/4 v14, 0x0
cmp-long v15, v8, v3
if-nez v15, :cond_22
if-nez v10, :cond_22
if-nez v12, :cond_22
if-nez v11, :cond_22
.line 7
iput-boolean v14, v1, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
const/4 v15, 0x1
goto :goto_2b
.line 8
:cond_22
iput-wide v3, v1, Lrx/internal/producers/ProducerObserverArbiter;->missedRequested:J
.line 9
iput-object v0, v1, Lrx/internal/producers/ProducerObserverArbiter;->missedProducer:Lrx/Producer;
.line 10
iput-object v0, v1, Lrx/internal/producers/ProducerObserverArbiter;->queue:Ljava/util/List;
.line 11
iput-object v0, v1, Lrx/internal/producers/ProducerObserverArbiter;->missedTerminal:Ljava/lang/Object;
const/4 v15, 0x0
.line 12
:goto_2b
monitor-exit p0
:try_end_2c
.catchall {:try_start_a .. :try_end_2c} :catchall_d3
if-eqz v15, :cond_38
cmp-long v0, v5, v3
if-eqz v0, :cond_37
if-eqz v7, :cond_37
.line 13
invoke-interface {v7, v5, v6}, Lrx/Producer;->request(J)V
:cond_37
return-void
:cond_38
if-eqz v12, :cond_42
.line 14
invoke-interface {v12}, Ljava/util/List;->isEmpty()Z
move-result v15
if-eqz v15, :cond_41
goto :goto_42
:cond_41
const/4 v13, 0x0
:cond_42
:goto_42
if-eqz v11, :cond_54
.line 15
sget-object v14, Ljava/lang/Boolean;->TRUE:Ljava/lang/Boolean;
if-eq v11, v14, :cond_4e
.line 16
check-cast v11, Ljava/lang/Throwable;
invoke-interface {v2, v11}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
return-void
:cond_4e
if-eqz v13, :cond_54
.line 17
invoke-interface {v2}, Lrx/Observer;->onCompleted()V
return-void
:cond_54
if-eqz v12, :cond_81
.line 18
invoke-interface {v12}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v11
:goto_5a
invoke-interface {v11}, Ljava/util/Iterator;->hasNext()Z
move-result v13
if-eqz v13, :cond_7a
invoke-interface {v11}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v13
.line 19
invoke-virtual {v2}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v14
if-eqz v14, :cond_6b
return-void
.line 20
:cond_6b
iget-boolean v14, v1, Lrx/internal/producers/ProducerObserverArbiter;->hasError:Z
if-eqz v14, :cond_70
goto :goto_9
.line 21
:cond_70
:try_start_70
invoke-interface {v2, v13}, Lrx/Observer;->onNext(Ljava/lang/Object;)V
:try_end_73
.catch Ljava/lang/Throwable; {:try_start_70 .. :try_end_73} :catch_74
goto :goto_5a
:catch_74
move-exception v0
move-object v3, v0
.line 22
invoke-static {v3, v2, v13}, Lrx/exceptions/Exceptions;->throwOrReport(Ljava/lang/Throwable;Lrx/Observer;Ljava/lang/Object;)V
return-void
.line 23
:cond_7a
invoke-interface {v12}, Ljava/util/List;->size()I
move-result v11
int-to-long v11, v11
add-long/2addr v11, v3
goto :goto_82
:cond_81
move-wide v11, v3
.line 24
:goto_82
iget-wide v13, v1, Lrx/internal/producers/ProducerObserverArbiter;->requested:J
const-wide v15, 0x7fffffffffffffffL
cmp-long v17, v13, v15
if-eqz v17, :cond_af
cmp-long v17, v8, v3
if-eqz v17, :cond_97
add-long/2addr v13, v8
cmp-long v17, v13, v3
if-gez v17, :cond_97
move-wide v13, v15
:cond_97
cmp-long v17, v11, v3
if-eqz v17, :cond_ad
cmp-long v17, v13, v15
if-eqz v17, :cond_ad
sub-long/2addr v13, v11
cmp-long v11, v13, v3
if-ltz v11, :cond_a5
goto :goto_ad
.line 25
:cond_a5
new-instance v0, Ljava/lang/IllegalStateException;
const-string v2, "More produced than requested"
invoke-direct {v0, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.line 26
:cond_ad
:goto_ad
iput-wide v13, v1, Lrx/internal/producers/ProducerObserverArbiter;->requested:J
:cond_af
if-eqz v10, :cond_c4
.line 27
sget-object v8, Lrx/internal/producers/ProducerObserverArbiter;->NULL_PRODUCER:Lrx/Producer;
if-ne v10, v8, :cond_b9
.line 28
iput-object v0, v1, Lrx/internal/producers/ProducerObserverArbiter;->currentProducer:Lrx/Producer;
goto/16 :goto_9
.line 29
:cond_b9
iput-object v10, v1, Lrx/internal/producers/ProducerObserverArbiter;->currentProducer:Lrx/Producer;
cmp-long v8, v13, v3
if-eqz v8, :cond_9
.line 30
invoke-static {v5, v6, v13, v14}, Lrx/internal/operators/BackpressureUtils;->addCap(JJ)J
move-result-wide v5
goto :goto_d0
.line 31
:cond_c4
iget-object v10, v1, Lrx/internal/producers/ProducerObserverArbiter;->currentProducer:Lrx/Producer;
if-eqz v10, :cond_9
cmp-long v11, v8, v3
if-eqz v11, :cond_9
.line 32
invoke-static {v5, v6, v8, v9}, Lrx/internal/operators/BackpressureUtils;->addCap(JJ)J
move-result-wide v5
:goto_d0
move-object v7, v10
goto/16 :goto_9
:catchall_d3
move-exception v0
.line 33
:try_start_d4
monitor-exit p0
:try_end_d5
.catchall {:try_start_d4 .. :try_end_d5} :catchall_d3
goto :goto_d7
:goto_d6
throw v0
:goto_d7
goto :goto_d6
.end method
.method public onCompleted()V
.registers 3
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
const/4 v1, 0x1
if-eqz v0, :cond_e
.line 3
invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v0
iput-object v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->missedTerminal:Ljava/lang/Object;
.line 4
monitor-exit p0
return-void
.line 5
:cond_e
iput-boolean v1, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
.line 6
monitor-exit p0
:try_end_11
.catchall {:try_start_1 .. :try_end_11} :catchall_17
.line 7
iget-object v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->child:Lrx/Subscriber;
invoke-interface {v0}, Lrx/Observer;->onCompleted()V
return-void
:catchall_17
move-exception v0
.line 8
:try_start_18
monitor-exit p0
:try_end_19
.catchall {:try_start_18 .. :try_end_19} :catchall_17
throw v0
.end method
.method public onError(Ljava/lang/Throwable;)V
.registers 4
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
const/4 v1, 0x1
if-eqz v0, :cond_a
.line 3
iput-object p1, p0, Lrx/internal/producers/ProducerObserverArbiter;->missedTerminal:Ljava/lang/Object;
const/4 v0, 0x0
goto :goto_d
.line 4
:cond_a
iput-boolean v1, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
const/4 v0, 0x1
.line 5
:goto_d
monitor-exit p0
:try_end_e
.catchall {:try_start_1 .. :try_end_e} :catchall_19
if-eqz v0, :cond_16
.line 6
iget-object v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->child:Lrx/Subscriber;
invoke-interface {v0, p1}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
goto :goto_18
.line 7
:cond_16
iput-boolean v1, p0, Lrx/internal/producers/ProducerObserverArbiter;->hasError:Z
:goto_18
return-void
:catchall_19
move-exception p1
.line 8
:try_start_1a
monitor-exit p0
:try_end_1b
.catchall {:try_start_1a .. :try_end_1b} :catchall_19
throw p1
.end method
.method public onNext(Ljava/lang/Object;)V
.registers 6
.annotation system Ldalvik/annotation/Signature;
value = {
"(TT;)V"
}
.end annotation
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
if-eqz v0, :cond_16
.line 3
iget-object v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->queue:Ljava/util/List;
if-nez v0, :cond_11
.line 4
new-instance v0, Ljava/util/ArrayList;
const/4 v1, 0x4
invoke-direct {v0, v1}, Ljava/util/ArrayList;-><init>(I)V
.line 5
iput-object v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->queue:Ljava/util/List;
.line 6
:cond_11
invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 7
monitor-exit p0
return-void
:cond_16
const/4 v0, 0x1
.line 8
iput-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
.line 9
monitor-exit p0
:try_end_1a
.catchall {:try_start_1 .. :try_end_1a} :catchall_3d
.line 10
:try_start_1a
iget-object v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->child:Lrx/Subscriber;
invoke-interface {v0, p1}, Lrx/Observer;->onNext(Ljava/lang/Object;)V
.line 11
iget-wide v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->requested:J
const-wide v2, 0x7fffffffffffffffL
cmp-long p1, v0, v2
if-eqz p1, :cond_2f
const-wide/16 v2, 0x1
sub-long/2addr v0, v2
.line 12
iput-wide v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->requested:J
.line 13
:cond_2f
invoke-virtual {p0}, Lrx/internal/producers/ProducerObserverArbiter;->emitLoop()V
:try_end_32
.catchall {:try_start_1a .. :try_end_32} :catchall_33
return-void
:catchall_33
move-exception p1
.line 14
monitor-enter p0
const/4 v0, 0x0
.line 15
:try_start_36
iput-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
.line 16
monitor-exit p0
:try_end_39
.catchall {:try_start_36 .. :try_end_39} :catchall_3a
throw p1
:catchall_3a
move-exception p1
:try_start_3b
monitor-exit p0
:try_end_3c
.catchall {:try_start_3b .. :try_end_3c} :catchall_3a
throw p1
:catchall_3d
move-exception p1
.line 17
:try_start_3e
monitor-exit p0
:try_end_3f
.catchall {:try_start_3e .. :try_end_3f} :catchall_3d
throw p1
.end method
.method public request(J)V
.registers 9
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/ProducerObserverArbiter;->emitting:Z
if-eqz v2, :cond_17
.line 3
iget-wide v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->missedRequested:J
add-long/2addr v0, p1
iput-wide v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->missedRequested:J
.line 4
monitor-exit p0
return-void
:cond_17
const/4 v2, 0x1
.line 5
iput-boolean v2, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
.line 6
monitor-exit p0
:try_end_1b
.catchall {:try_start_c .. :try_end_1b} :catchall_3e
.line 7
iget-object v2, p0, Lrx/internal/producers/ProducerObserverArbiter;->currentProducer:Lrx/Producer;
.line 8
:try_start_1d
iget-wide v3, p0, Lrx/internal/producers/ProducerObserverArbiter;->requested:J
add-long/2addr v3, p1
cmp-long v5, v3, v0
if-gez v5, :cond_29
const-wide v3, 0x7fffffffffffffffL
.line 9
:cond_29
iput-wide v3, p0, Lrx/internal/producers/ProducerObserverArbiter;->requested:J
.line 10
invoke-virtual {p0}, Lrx/internal/producers/ProducerObserverArbiter;->emitLoop()V
:try_end_2e
.catchall {:try_start_1d .. :try_end_2e} :catchall_34
if-eqz v2, :cond_33
.line 11
invoke-interface {v2, p1, p2}, Lrx/Producer;->request(J)V
:cond_33
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/ProducerObserverArbiter;->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 7
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
if-eqz v0, :cond_e
if-eqz p1, :cond_8
goto :goto_a
.line 3
:cond_8
sget-object p1, Lrx/internal/producers/ProducerObserverArbiter;->NULL_PRODUCER:Lrx/Producer;
:goto_a
iput-object p1, p0, Lrx/internal/producers/ProducerObserverArbiter;->missedProducer:Lrx/Producer;
.line 4
monitor-exit p0
return-void
:cond_e
const/4 v0, 0x1
.line 5
iput-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
.line 6
monitor-exit p0
:try_end_12
.catchall {:try_start_1 .. :try_end_12} :catchall_2f
.line 7
iput-object p1, p0, Lrx/internal/producers/ProducerObserverArbiter;->currentProducer:Lrx/Producer;
.line 8
iget-wide v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->requested:J
.line 9
:try_start_16
invoke-virtual {p0}, Lrx/internal/producers/ProducerObserverArbiter;->emitLoop()V
:try_end_19
.catchall {:try_start_16 .. :try_end_19} :catchall_25
if-eqz p1, :cond_24
const-wide/16 v2, 0x0
cmp-long v4, v0, v2
if-eqz v4, :cond_24
.line 10
invoke-interface {p1, v0, v1}, Lrx/Producer;->request(J)V
:cond_24
return-void
:catchall_25
move-exception p1
.line 11
monitor-enter p0
const/4 v0, 0x0
.line 12
:try_start_28
iput-boolean v0, p0, Lrx/internal/producers/ProducerObserverArbiter;->emitting:Z
.line 13
monitor-exit p0
:try_end_2b
.catchall {:try_start_28 .. :try_end_2b} :catchall_2c
throw p1
:catchall_2c
move-exception p1
:try_start_2d
monitor-exit p0
:try_end_2e
.catchall {:try_start_2d .. :try_end_2e} :catchall_2c
throw p1
:catchall_2f
move-exception p1
.line 14
:try_start_30
monitor-exit p0
:try_end_31
.catchall {:try_start_30 .. :try_end_31} :catchall_2f
throw p1
.end method