UnicastSubject$State.smali
.class final Lrx/subjects/UnicastSubject$State;
.super Ljava/util/concurrent/atomic/AtomicLong;
.source "UnicastSubject.java"
# interfaces
.implements Lrx/Producer;
.implements Lrx/Observer;
.implements Lrx/Observable$OnSubscribe;
.implements Lrx/Subscription;
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lrx/subjects/UnicastSubject;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x18
name = "State"
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">",
"Ljava/util/concurrent/atomic/AtomicLong;",
"Lrx/Producer;",
"Lrx/Observer<",
"TT;>;",
"Lrx/Observable$OnSubscribe<",
"TT;>;",
"Lrx/Subscription;"
}
.end annotation
# static fields
.field private static final serialVersionUID:J = -0x7d831d73a4227baaL
# instance fields
.field volatile caughtUp:Z
.field final delayError:Z
.field volatile done:Z
.field emitting:Z
.field error:Ljava/lang/Throwable;
.field missed:Z
.field final queue:Ljava/util/Queue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/Queue<",
"Ljava/lang/Object;",
">;"
}
.end annotation
.end field
.field final subscriber:Ljava/util/concurrent/atomic/AtomicReference;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/atomic/AtomicReference<",
"Lrx/Subscriber<",
"-TT;>;>;"
}
.end annotation
.end field
.field final terminateOnce:Ljava/util/concurrent/atomic/AtomicReference;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/atomic/AtomicReference<",
"Lrx/functions/Action0;",
">;"
}
.end annotation
.end field
# direct methods
.method public constructor <init>(IZLrx/functions/Action0;)V
.registers 5
.line 1
invoke-direct {p0}, Ljava/util/concurrent/atomic/AtomicLong;-><init>()V
.line 2
new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;
invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicReference;-><init>()V
iput-object v0, p0, Lrx/subjects/UnicastSubject$State;->subscriber:Ljava/util/concurrent/atomic/AtomicReference;
if-eqz p3, :cond_12
.line 3
new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;
invoke-direct {v0, p3}, Ljava/util/concurrent/atomic/AtomicReference;-><init>(Ljava/lang/Object;)V
goto :goto_13
:cond_12
const/4 v0, 0x0
:goto_13
iput-object v0, p0, Lrx/subjects/UnicastSubject$State;->terminateOnce:Ljava/util/concurrent/atomic/AtomicReference;
.line 4
iput-boolean p2, p0, Lrx/subjects/UnicastSubject$State;->delayError:Z
const/4 p2, 0x1
if-le p1, p2, :cond_2c
.line 5
invoke-static {}, Lrx/internal/util/unsafe/UnsafeAccess;->isUnsafeAvailable()Z
move-result p2
if-eqz p2, :cond_26
new-instance p2, Lrx/internal/util/unsafe/SpscUnboundedArrayQueue;
invoke-direct {p2, p1}, Lrx/internal/util/unsafe/SpscUnboundedArrayQueue;-><init>(I)V
goto :goto_3e
:cond_26
new-instance p2, Lrx/internal/util/atomic/SpscUnboundedAtomicArrayQueue;
invoke-direct {p2, p1}, Lrx/internal/util/atomic/SpscUnboundedAtomicArrayQueue;-><init>(I)V
goto :goto_3e
.line 6
:cond_2c
invoke-static {}, Lrx/internal/util/unsafe/UnsafeAccess;->isUnsafeAvailable()Z
move-result p1
if-eqz p1, :cond_38
new-instance p1, Lrx/internal/util/unsafe/SpscLinkedQueue;
invoke-direct {p1}, Lrx/internal/util/unsafe/SpscLinkedQueue;-><init>()V
goto :goto_3d
:cond_38
new-instance p1, Lrx/internal/util/atomic/SpscLinkedAtomicQueue;
invoke-direct {p1}, Lrx/internal/util/atomic/SpscLinkedAtomicQueue;-><init>()V
:goto_3d
move-object p2, p1
.line 7
:goto_3e
iput-object p2, p0, Lrx/subjects/UnicastSubject$State;->queue:Ljava/util/Queue;
return-void
.end method
# virtual methods
.method public bridge synthetic call(Ljava/lang/Object;)V
.registers 2
.line 1
check-cast p1, Lrx/Subscriber;
invoke-virtual {p0, p1}, Lrx/subjects/UnicastSubject$State;->call(Lrx/Subscriber;)V
return-void
.end method
.method public call(Lrx/Subscriber;)V
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lrx/Subscriber<",
"-TT;>;)V"
}
.end annotation
.line 2
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->subscriber:Ljava/util/concurrent/atomic/AtomicReference;
const/4 v1, 0x0
invoke-virtual {v0, v1, p1}, Ljava/util/concurrent/atomic/AtomicReference;->compareAndSet(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_10
.line 3
invoke-virtual {p1, p0}, Lrx/Subscriber;->add(Lrx/Subscription;)V
.line 4
invoke-virtual {p1, p0}, Lrx/Subscriber;->setProducer(Lrx/Producer;)V
goto :goto_1a
.line 5
:cond_10
new-instance v0, Ljava/lang/IllegalStateException;
const-string v1, "Only a single subscriber is allowed"
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
invoke-interface {p1, v0}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
:goto_1a
return-void
.end method
.method checkTerminated(ZZZLrx/Subscriber;)Z
.registers 7
.annotation system Ldalvik/annotation/Signature;
value = {
"(ZZZ",
"Lrx/Subscriber<",
"-TT;>;)Z"
}
.end annotation
.line 1
invoke-virtual {p4}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v0
const/4 v1, 0x1
if-eqz v0, :cond_d
.line 2
iget-object p1, p0, Lrx/subjects/UnicastSubject$State;->queue:Ljava/util/Queue;
invoke-interface {p1}, Ljava/util/Queue;->clear()V
return v1
:cond_d
if-eqz p1, :cond_2a
.line 3
iget-object p1, p0, Lrx/subjects/UnicastSubject$State;->error:Ljava/lang/Throwable;
if-eqz p1, :cond_1e
if-nez p3, :cond_1e
.line 4
iget-object p2, p0, Lrx/subjects/UnicastSubject$State;->queue:Ljava/util/Queue;
invoke-interface {p2}, Ljava/util/Queue;->clear()V
.line 5
invoke-interface {p4, p1}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
return v1
:cond_1e
if-eqz p2, :cond_2a
if-eqz p1, :cond_26
.line 6
invoke-interface {p4, p1}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
goto :goto_29
.line 7
:cond_26
invoke-interface {p4}, Lrx/Observer;->onCompleted()V
:goto_29
return v1
:cond_2a
const/4 p1, 0x0
return p1
.end method
.method doTerminate()V
.registers 4
.line 1
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->terminateOnce:Ljava/util/concurrent/atomic/AtomicReference;
if-eqz v0, :cond_16
.line 2
invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lrx/functions/Action0;
if-eqz v1, :cond_16
const/4 v2, 0x0
.line 3
invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/atomic/AtomicReference;->compareAndSet(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_16
.line 4
invoke-interface {v1}, Lrx/functions/Action0;->call()V
:cond_16
return-void
.end method
.method public isUnsubscribed()Z
.registers 2
.line 1
iget-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->done:Z
return v0
.end method
.method public onCompleted()V
.registers 3
.line 1
iget-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->done:Z
if-nez v0, :cond_2a
.line 2
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->doTerminate()V
const/4 v0, 0x1
.line 3
iput-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->done:Z
.line 4
iget-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->caughtUp:Z
if-nez v1, :cond_1f
.line 5
monitor-enter p0
.line 6
:try_start_f
iget-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->caughtUp:Z
if-nez v1, :cond_14
goto :goto_15
:cond_14
const/4 v0, 0x0
.line 7
:goto_15
monitor-exit p0
:try_end_16
.catchall {:try_start_f .. :try_end_16} :catchall_1c
if-eqz v0, :cond_1f
.line 8
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->replay()V
return-void
:catchall_1c
move-exception v0
.line 9
:try_start_1d
monitor-exit p0
:try_end_1e
.catchall {:try_start_1d .. :try_end_1e} :catchall_1c
throw v0
.line 10
:cond_1f
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->subscriber:Ljava/util/concurrent/atomic/AtomicReference;
invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lrx/Subscriber;
invoke-interface {v0}, Lrx/Observer;->onCompleted()V
:cond_2a
return-void
.end method
.method public onError(Ljava/lang/Throwable;)V
.registers 4
.line 1
iget-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->done:Z
if-nez v0, :cond_2c
.line 2
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->doTerminate()V
.line 3
iput-object p1, p0, Lrx/subjects/UnicastSubject$State;->error:Ljava/lang/Throwable;
const/4 v0, 0x1
.line 4
iput-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->done:Z
.line 5
iget-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->caughtUp:Z
if-nez v1, :cond_21
.line 6
monitor-enter p0
.line 7
:try_start_11
iget-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->caughtUp:Z
if-nez v1, :cond_16
goto :goto_17
:cond_16
const/4 v0, 0x0
.line 8
:goto_17
monitor-exit p0
:try_end_18
.catchall {:try_start_11 .. :try_end_18} :catchall_1e
if-eqz v0, :cond_21
.line 9
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->replay()V
return-void
:catchall_1e
move-exception p1
.line 10
:try_start_1f
monitor-exit p0
:try_end_20
.catchall {:try_start_1f .. :try_end_20} :catchall_1e
throw p1
.line 11
:cond_21
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->subscriber:Ljava/util/concurrent/atomic/AtomicReference;
invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lrx/Subscriber;
invoke-interface {v0, p1}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
:cond_2c
return-void
.end method
.method public onNext(Ljava/lang/Object;)V
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(TT;)V"
}
.end annotation
.line 1
iget-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->done:Z
if-nez v0, :cond_32
.line 2
iget-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->caughtUp:Z
if-nez v0, :cond_22
const/4 v0, 0x0
.line 3
monitor-enter p0
.line 4
:try_start_a
iget-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->caughtUp:Z
if-nez v1, :cond_18
.line 5
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->queue:Ljava/util/Queue;
invoke-static {p1}, Lrx/internal/operators/NotificationLite;->next(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/Queue;->offer(Ljava/lang/Object;)Z
const/4 v0, 0x1
.line 6
:cond_18
monitor-exit p0
:try_end_19
.catchall {:try_start_a .. :try_end_19} :catchall_1f
if-eqz v0, :cond_22
.line 7
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->replay()V
return-void
:catchall_1f
move-exception p1
.line 8
:try_start_20
monitor-exit p0
:try_end_21
.catchall {:try_start_20 .. :try_end_21} :catchall_1f
throw p1
.line 9
:cond_22
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->subscriber:Ljava/util/concurrent/atomic/AtomicReference;
invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lrx/Subscriber;
.line 10
:try_start_2a
invoke-interface {v0, p1}, Lrx/Observer;->onNext(Ljava/lang/Object;)V
:try_end_2d
.catch Ljava/lang/Throwable; {:try_start_2a .. :try_end_2d} :catch_2e
goto :goto_32
:catch_2e
move-exception v1
.line 11
invoke-static {v1, v0, p1}, Lrx/exceptions/Exceptions;->throwOrReport(Ljava/lang/Throwable;Lrx/Observer;Ljava/lang/Object;)V
:cond_32
:goto_32
return-void
.end method
.method replay()V
.registers 16
.line 1
monitor-enter p0
.line 2
:try_start_1
iget-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->emitting:Z
const/4 v1, 0x1
if-eqz v0, :cond_a
.line 3
iput-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->missed:Z
.line 4
monitor-exit p0
return-void
.line 5
:cond_a
iput-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->emitting:Z
.line 6
monitor-exit p0
:try_end_d
.catchall {:try_start_1 .. :try_end_d} :catchall_97
.line 7
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->queue:Ljava/util/Queue;
.line 8
iget-boolean v2, p0, Lrx/subjects/UnicastSubject$State;->delayError:Z
.line 9
:goto_11
iget-object v3, p0, Lrx/subjects/UnicastSubject$State;->subscriber:Ljava/util/concurrent/atomic/AtomicReference;
invoke-virtual {v3}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
move-result-object v3
check-cast v3, Lrx/Subscriber;
const/4 v4, 0x0
if-eqz v3, :cond_7b
.line 10
iget-boolean v5, p0, Lrx/subjects/UnicastSubject$State;->done:Z
.line 11
invoke-interface {v0}, Ljava/util/Queue;->isEmpty()Z
move-result v6
.line 12
invoke-virtual {p0, v5, v6, v2, v3}, Lrx/subjects/UnicastSubject$State;->checkTerminated(ZZZLrx/Subscriber;)Z
move-result v5
if-eqz v5, :cond_29
return-void
.line 13
:cond_29
invoke-virtual {p0}, Ljava/util/concurrent/atomic/AtomicLong;->get()J
move-result-wide v5
const-wide v7, 0x7fffffffffffffffL
cmp-long v9, v5, v7
if-nez v9, :cond_38
const/4 v7, 0x1
goto :goto_39
:cond_38
const/4 v7, 0x0
:goto_39
const-wide/16 v8, 0x0
move-wide v10, v8
:goto_3c
cmp-long v12, v5, v8
if-eqz v12, :cond_70
.line 14
iget-boolean v12, p0, Lrx/subjects/UnicastSubject$State;->done:Z
.line 15
invoke-interface {v0}, Ljava/util/Queue;->poll()Ljava/lang/Object;
move-result-object v13
if-nez v13, :cond_4a
const/4 v14, 0x1
goto :goto_4b
:cond_4a
const/4 v14, 0x0
.line 16
:goto_4b
invoke-virtual {p0, v12, v14, v2, v3}, Lrx/subjects/UnicastSubject$State;->checkTerminated(ZZZLrx/Subscriber;)Z
move-result v12
if-eqz v12, :cond_52
return-void
:cond_52
if-eqz v14, :cond_55
goto :goto_70
.line 17
:cond_55
invoke-static {v13}, Lrx/internal/operators/NotificationLite;->getValue(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v12
.line 18
:try_start_59
invoke-interface {v3, v12}, Lrx/Observer;->onNext(Ljava/lang/Object;)V
:try_end_5c
.catch Ljava/lang/Throwable; {:try_start_59 .. :try_end_5c} :catch_61
const-wide/16 v12, 0x1
sub-long/2addr v5, v12
add-long/2addr v10, v12
goto :goto_3c
:catch_61
move-exception v1
.line 19
invoke-interface {v0}, Ljava/util/Queue;->clear()V
.line 20
invoke-static {v1}, Lrx/exceptions/Exceptions;->throwIfFatal(Ljava/lang/Throwable;)V
.line 21
invoke-static {v1, v12}, Lrx/exceptions/OnErrorThrowable;->addValueAsLastCause(Ljava/lang/Throwable;Ljava/lang/Object;)Ljava/lang/Throwable;
move-result-object v0
invoke-interface {v3, v0}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
return-void
:cond_70
:goto_70
if-nez v7, :cond_7c
cmp-long v3, v10, v8
if-eqz v3, :cond_7c
neg-long v5, v10
.line 22
invoke-virtual {p0, v5, v6}, Ljava/util/concurrent/atomic/AtomicLong;->addAndGet(J)J
goto :goto_7c
:cond_7b
const/4 v7, 0x0
.line 23
:cond_7c
:goto_7c
monitor-enter p0
.line 24
:try_start_7d
iget-boolean v3, p0, Lrx/subjects/UnicastSubject$State;->missed:Z
if-nez v3, :cond_8f
if-eqz v7, :cond_8b
.line 25
invoke-interface {v0}, Ljava/util/Queue;->isEmpty()Z
move-result v0
if-eqz v0, :cond_8b
.line 26
iput-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->caughtUp:Z
.line 27
:cond_8b
iput-boolean v4, p0, Lrx/subjects/UnicastSubject$State;->emitting:Z
.line 28
monitor-exit p0
return-void
.line 29
:cond_8f
iput-boolean v4, p0, Lrx/subjects/UnicastSubject$State;->missed:Z
.line 30
monitor-exit p0
goto/16 :goto_11
:catchall_94
move-exception v0
monitor-exit p0
:try_end_96
.catchall {:try_start_7d .. :try_end_96} :catchall_94
throw v0
:catchall_97
move-exception v0
.line 31
:try_start_98
monitor-exit p0
:try_end_99
.catchall {:try_start_98 .. :try_end_99} :catchall_97
goto :goto_9b
:goto_9a
throw v0
:goto_9b
goto :goto_9a
.end method
.method public request(J)V
.registers 6
const-wide/16 v0, 0x0
cmp-long v2, p1, v0
if-ltz v2, :cond_19
cmp-long v2, p1, v0
if-lez v2, :cond_11
.line 1
invoke-static {p0, p1, p2}, Lrx/internal/operators/BackpressureUtils;->getAndAddRequest(Ljava/util/concurrent/atomic/AtomicLong;J)J
.line 2
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->replay()V
goto :goto_18
.line 3
:cond_11
iget-boolean p1, p0, Lrx/subjects/UnicastSubject$State;->done:Z
if-eqz p1, :cond_18
.line 4
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->replay()V
:cond_18
:goto_18
return-void
.line 5
:cond_19
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 unsubscribe()V
.registers 3
.line 1
invoke-virtual {p0}, Lrx/subjects/UnicastSubject$State;->doTerminate()V
const/4 v0, 0x1
.line 2
iput-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->done:Z
.line 3
monitor-enter p0
.line 4
:try_start_7
iget-boolean v1, p0, Lrx/subjects/UnicastSubject$State;->emitting:Z
if-eqz v1, :cond_d
.line 5
monitor-exit p0
return-void
.line 6
:cond_d
iput-boolean v0, p0, Lrx/subjects/UnicastSubject$State;->emitting:Z
.line 7
monitor-exit p0
:try_end_10
.catchall {:try_start_7 .. :try_end_10} :catchall_16
.line 8
iget-object v0, p0, Lrx/subjects/UnicastSubject$State;->queue:Ljava/util/Queue;
invoke-interface {v0}, Ljava/util/Queue;->clear()V
return-void
:catchall_16
move-exception v0
.line 9
:try_start_17
monitor-exit p0
:try_end_18
.catchall {:try_start_17 .. :try_end_18} :catchall_16
throw v0
.end method