CachedObservable$ReplayProducer.smali
.class final Lrx/internal/operators/CachedObservable$ReplayProducer;
.super Ljava/util/concurrent/atomic/AtomicLong;
.source "CachedObservable.java"
# interfaces
.implements Lrx/Producer;
.implements Lrx/Subscription;
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lrx/internal/operators/CachedObservable;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x18
name = "ReplayProducer"
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">",
"Ljava/util/concurrent/atomic/AtomicLong;",
"Lrx/Producer;",
"Lrx/Subscription;"
}
.end annotation
# static fields
.field private static final serialVersionUID:J = -0x237e491daced6e1dL
# instance fields
.field final child:Lrx/Subscriber;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lrx/Subscriber<",
"-TT;>;"
}
.end annotation
.end field
.field currentBuffer:[Ljava/lang/Object;
.field currentIndexInBuffer:I
.field emitting:Z
.field index:I
.field missed:Z
.field final state:Lrx/internal/operators/CachedObservable$CacheState;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lrx/internal/operators/CachedObservable$CacheState<",
"TT;>;"
}
.end annotation
.end field
# direct methods
.method public constructor <init>(Lrx/Subscriber;Lrx/internal/operators/CachedObservable$CacheState;)V
.registers 3
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lrx/Subscriber<",
"-TT;>;",
"Lrx/internal/operators/CachedObservable$CacheState<",
"TT;>;)V"
}
.end annotation
.line 1
invoke-direct {p0}, Ljava/util/concurrent/atomic/AtomicLong;-><init>()V
.line 2
iput-object p1, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->child:Lrx/Subscriber;
.line 3
iput-object p2, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->state:Lrx/internal/operators/CachedObservable$CacheState;
return-void
.end method
# virtual methods
.method public isUnsubscribed()Z
.registers 6
.line 1
invoke-virtual {p0}, Ljava/util/concurrent/atomic/AtomicLong;->get()J
move-result-wide v0
const-wide/16 v2, 0x0
cmp-long v4, v0, v2
if-gez v4, :cond_c
const/4 v0, 0x1
goto :goto_d
:cond_c
const/4 v0, 0x0
:goto_d
return v0
.end method
.method public produced(J)J
.registers 3
neg-long p1, p1
.line 1
invoke-virtual {p0, p1, p2}, Ljava/util/concurrent/atomic/AtomicLong;->addAndGet(J)J
move-result-wide p1
return-wide p1
.end method
.method public replay()V
.registers 16
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-boolean v0, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->emitting:Z
const/4 v1, 0x1
if-eqz v0, :cond_a
.line 3
iput-boolean v1, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->missed:Z
.line 4
monitor-exit p0
return-void
.line 5
:cond_a
iput-boolean v1, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->emitting:Z
.line 6
monitor-exit p0
:try_end_d
.catchall {:try_start_1 .. :try_end_d} :catchall_e8
const/4 v0, 0x0
.line 7
:try_start_e
iget-object v2, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->child:Lrx/Subscriber;
.line 8
:goto_10
invoke-virtual {p0}, Ljava/util/concurrent/atomic/AtomicLong;->get()J
move-result-wide v3
const-wide/16 v5, 0x0
cmp-long v7, v3, v5
if-gez v7, :cond_1b
return-void
.line 9
:cond_1b
iget-object v7, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->state:Lrx/internal/operators/CachedObservable$CacheState;
invoke-virtual {v7}, Lrx/internal/util/LinkedArrayList;->size()I
move-result v7
if-eqz v7, :cond_c3
.line 10
iget-object v8, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->currentBuffer:[Ljava/lang/Object;
if-nez v8, :cond_2f
.line 11
iget-object v8, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->state:Lrx/internal/operators/CachedObservable$CacheState;
invoke-virtual {v8}, Lrx/internal/util/LinkedArrayList;->head()[Ljava/lang/Object;
move-result-object v8
.line 12
iput-object v8, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->currentBuffer:[Ljava/lang/Object;
.line 13
:cond_2f
array-length v9, v8
sub-int/2addr v9, v1
.line 14
iget v10, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->index:I
.line 15
iget v11, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->currentIndexInBuffer:I
cmp-long v12, v3, v5
if-nez v12, :cond_5e
.line 16
aget-object v3, v8, v11
.line 17
invoke-static {v3}, Lrx/internal/operators/NotificationLite;->isCompleted(Ljava/lang/Object;)Z
move-result v4
if-eqz v4, :cond_4d
.line 18
invoke-interface {v2}, Lrx/Observer;->onCompleted()V
:try_end_44
.catchall {:try_start_e .. :try_end_44} :catchall_db
.line 19
:try_start_44
invoke-virtual {p0}, Lrx/internal/operators/CachedObservable$ReplayProducer;->unsubscribe()V
:try_end_47
.catchall {:try_start_44 .. :try_end_47} :catchall_48
return-void
:catchall_48
move-exception v2
move-object v1, v2
const/4 v4, 0x1
goto/16 :goto_dd
.line 20
:cond_4d
:try_start_4d
invoke-static {v3}, Lrx/internal/operators/NotificationLite;->isError(Ljava/lang/Object;)Z
move-result v4
if-eqz v4, :cond_c3
.line 21
invoke-static {v3}, Lrx/internal/operators/NotificationLite;->getError(Ljava/lang/Object;)Ljava/lang/Throwable;
move-result-object v3
invoke-interface {v2, v3}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
:try_end_5a
.catchall {:try_start_4d .. :try_end_5a} :catchall_db
.line 22
:try_start_5a
invoke-virtual {p0}, Lrx/internal/operators/CachedObservable$ReplayProducer;->unsubscribe()V
:try_end_5d
.catchall {:try_start_5a .. :try_end_5d} :catchall_48
return-void
:cond_5e
cmp-long v12, v3, v5
if-lez v12, :cond_c3
const/4 v12, 0x0
:goto_63
if-ge v10, v7, :cond_b2
cmp-long v13, v3, v5
if-lez v13, :cond_b2
.line 23
:try_start_69
invoke-virtual {v2}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v13
if-eqz v13, :cond_70
return-void
:cond_70
if-ne v11, v9, :cond_77
.line 24
aget-object v8, v8, v9
check-cast v8, [Ljava/lang/Object;
const/4 v11, 0x0
.line 25
:cond_77
aget-object v13, v8, v11
:try_end_79
.catchall {:try_start_69 .. :try_end_79} :catchall_db
.line 26
:try_start_79
invoke-static {v2, v13}, Lrx/internal/operators/NotificationLite;->accept(Lrx/Observer;Ljava/lang/Object;)Z
move-result v14
:try_end_7d
.catch Ljava/lang/Throwable; {:try_start_79 .. :try_end_7d} :catch_90
.catchall {:try_start_79 .. :try_end_7d} :catchall_db
if-eqz v14, :cond_86
.line 27
:try_start_7f
invoke-virtual {p0}, Lrx/internal/operators/CachedObservable$ReplayProducer;->unsubscribe()V
:try_end_82
.catch Ljava/lang/Throwable; {:try_start_7f .. :try_end_82} :catch_83
.catchall {:try_start_7f .. :try_end_82} :catchall_48
return-void
:catch_83
move-exception v3
const/4 v4, 0x1
goto :goto_92
:cond_86
add-int/lit8 v11, v11, 0x1
add-int/lit8 v10, v10, 0x1
const-wide/16 v13, 0x1
sub-long/2addr v3, v13
add-int/lit8 v12, v12, 0x1
goto :goto_63
:catch_90
move-exception v3
const/4 v4, 0x0
.line 28
:goto_92
:try_start_92
invoke-static {v3}, Lrx/exceptions/Exceptions;->throwIfFatal(Ljava/lang/Throwable;)V
:try_end_95
.catchall {:try_start_92 .. :try_end_95} :catchall_b0
.line 29
:try_start_95
invoke-virtual {p0}, Lrx/internal/operators/CachedObservable$ReplayProducer;->unsubscribe()V
.line 30
invoke-static {v13}, Lrx/internal/operators/NotificationLite;->isError(Ljava/lang/Object;)Z
move-result v4
if-nez v4, :cond_af
invoke-static {v13}, Lrx/internal/operators/NotificationLite;->isCompleted(Ljava/lang/Object;)Z
move-result v4
if-nez v4, :cond_af
.line 31
invoke-static {v13}, Lrx/internal/operators/NotificationLite;->getValue(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v4
invoke-static {v3, v4}, Lrx/exceptions/OnErrorThrowable;->addValueAsLastCause(Ljava/lang/Throwable;Ljava/lang/Object;)Ljava/lang/Throwable;
move-result-object v3
invoke-interface {v2, v3}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
:try_end_af
.catchall {:try_start_95 .. :try_end_af} :catchall_48
:cond_af
return-void
:catchall_b0
move-exception v1
goto :goto_dd
.line 32
:cond_b2
:try_start_b2
invoke-virtual {v2}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v3
if-eqz v3, :cond_b9
return-void
.line 33
:cond_b9
iput v10, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->index:I
.line 34
iput v11, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->currentIndexInBuffer:I
.line 35
iput-object v8, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->currentBuffer:[Ljava/lang/Object;
int-to-long v3, v12
.line 36
invoke-virtual {p0, v3, v4}, Lrx/internal/operators/CachedObservable$ReplayProducer;->produced(J)J
.line 37
:cond_c3
monitor-enter p0
:try_end_c4
.catchall {:try_start_b2 .. :try_end_c4} :catchall_db
.line 38
:try_start_c4
iget-boolean v3, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->missed:Z
if-nez v3, :cond_cc
.line 39
iput-boolean v0, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->emitting:Z
:try_end_ca
.catchall {:try_start_c4 .. :try_end_ca} :catchall_d1
.line 40
:try_start_ca
monitor-exit p0
:try_end_cb
.catchall {:try_start_ca .. :try_end_cb} :catchall_d9
return-void
.line 41
:cond_cc
:try_start_cc
iput-boolean v0, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->missed:Z
.line 42
monitor-exit p0
:try_end_cf
.catchall {:try_start_cc .. :try_end_cf} :catchall_d1
goto/16 :goto_10
:catchall_d1
move-exception v2
const/4 v1, 0x0
:goto_d3
:try_start_d3
monitor-exit p0
:try_end_d4
.catchall {:try_start_d3 .. :try_end_d4} :catchall_d9
:try_start_d4
throw v2
:try_end_d5
.catchall {:try_start_d4 .. :try_end_d5} :catchall_d5
:catchall_d5
move-exception v2
move v4, v1
move-object v1, v2
goto :goto_dd
:catchall_d9
move-exception v2
goto :goto_d3
:catchall_db
move-exception v1
const/4 v4, 0x0
:goto_dd
if-nez v4, :cond_e7
.line 43
monitor-enter p0
.line 44
:try_start_e0
iput-boolean v0, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->emitting:Z
.line 45
monitor-exit p0
goto :goto_e7
:catchall_e4
move-exception v0
monitor-exit p0
:try_end_e6
.catchall {:try_start_e0 .. :try_end_e6} :catchall_e4
throw v0
:cond_e7
:goto_e7
throw v1
:catchall_e8
move-exception v0
.line 46
:try_start_e9
monitor-exit p0
:try_end_ea
.catchall {:try_start_e9 .. :try_end_ea} :catchall_e8
goto :goto_ec
:goto_eb
throw v0
:goto_ec
goto :goto_eb
.end method
.method public request(J)V
.registers 10
.line 1
:cond_0
invoke-virtual {p0}, Ljava/util/concurrent/atomic/AtomicLong;->get()J
move-result-wide v0
const-wide/16 v2, 0x0
cmp-long v4, v0, v2
if-gez v4, :cond_b
return-void
:cond_b
add-long v4, v0, p1
cmp-long v6, v4, v2
if-gez v6, :cond_16
const-wide v4, 0x7fffffffffffffffL
.line 2
:cond_16
invoke-virtual {p0, v0, v1, v4, v5}, Ljava/util/concurrent/atomic/AtomicLong;->compareAndSet(JJ)Z
move-result v0
if-eqz v0, :cond_0
.line 3
invoke-virtual {p0}, Lrx/internal/operators/CachedObservable$ReplayProducer;->replay()V
return-void
.end method
.method public unsubscribe()V
.registers 6
.line 1
invoke-virtual {p0}, Ljava/util/concurrent/atomic/AtomicLong;->get()J
move-result-wide v0
const-wide/16 v2, 0x0
cmp-long v4, v0, v2
if-ltz v4, :cond_19
const-wide/16 v0, -0x1
.line 2
invoke-virtual {p0, v0, v1}, Ljava/util/concurrent/atomic/AtomicLong;->getAndSet(J)J
move-result-wide v0
cmp-long v4, v0, v2
if-ltz v4, :cond_19
.line 3
iget-object v0, p0, Lrx/internal/operators/CachedObservable$ReplayProducer;->state:Lrx/internal/operators/CachedObservable$CacheState;
invoke-virtual {v0, p0}, Lrx/internal/operators/CachedObservable$CacheState;->removeProducer(Lrx/internal/operators/CachedObservable$ReplayProducer;)V
:cond_19
return-void
.end method