OperatorObserveOn$ObserveOnSubscriber.smali
.class final Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;
.super Lrx/Subscriber;
.source "OperatorObserveOn.java"
# interfaces
.implements Lrx/functions/Action0;
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lrx/internal/operators/OperatorObserveOn;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x18
name = "ObserveOnSubscriber"
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">",
"Lrx/Subscriber<",
"TT;>;",
"Lrx/functions/Action0;"
}
.end annotation
# instance fields
.field final child:Lrx/Subscriber;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lrx/Subscriber<",
"-TT;>;"
}
.end annotation
.end field
.field final counter:Ljava/util/concurrent/atomic/AtomicLong;
.field final delayError:Z
.field emitted:J
.field error:Ljava/lang/Throwable;
.field volatile finished:Z
.field final limit:I
.field final queue:Ljava/util/Queue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/Queue<",
"Ljava/lang/Object;",
">;"
}
.end annotation
.end field
.field final recursiveScheduler:Lrx/Scheduler$Worker;
.field final requested:Ljava/util/concurrent/atomic/AtomicLong;
# direct methods
.method public constructor <init>(Lrx/Scheduler;Lrx/Subscriber;ZI)V
.registers 6
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lrx/Scheduler;",
"Lrx/Subscriber<",
"-TT;>;ZI)V"
}
.end annotation
.line 1
invoke-direct {p0}, Lrx/Subscriber;-><init>()V
.line 2
new-instance v0, Ljava/util/concurrent/atomic/AtomicLong;
invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicLong;-><init>()V
iput-object v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->requested:Ljava/util/concurrent/atomic/AtomicLong;
.line 3
new-instance v0, Ljava/util/concurrent/atomic/AtomicLong;
invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicLong;-><init>()V
iput-object v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->counter:Ljava/util/concurrent/atomic/AtomicLong;
.line 4
iput-object p2, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->child:Lrx/Subscriber;
.line 5
invoke-virtual {p1}, Lrx/Scheduler;->createWorker()Lrx/Scheduler$Worker;
move-result-object p1
iput-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
.line 6
iput-boolean p3, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->delayError:Z
if-lez p4, :cond_1e
goto :goto_20
.line 7
:cond_1e
sget p4, Lrx/internal/util/RxRingBuffer;->SIZE:I
:goto_20
shr-int/lit8 p1, p4, 0x2
sub-int p1, p4, p1
.line 8
iput p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->limit:I
.line 9
invoke-static {}, Lrx/internal/util/unsafe/UnsafeAccess;->isUnsafeAvailable()Z
move-result p1
if-eqz p1, :cond_34
.line 10
new-instance p1, Lrx/internal/util/unsafe/SpscArrayQueue;
invoke-direct {p1, p4}, Lrx/internal/util/unsafe/SpscArrayQueue;-><init>(I)V
iput-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->queue:Ljava/util/Queue;
goto :goto_3b
.line 11
:cond_34
new-instance p1, Lrx/internal/util/atomic/SpscAtomicArrayQueue;
invoke-direct {p1, p4}, Lrx/internal/util/atomic/SpscAtomicArrayQueue;-><init>(I)V
iput-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->queue:Ljava/util/Queue;
:goto_3b
int-to-long p1, p4
.line 12
invoke-virtual {p0, p1, p2}, Lrx/Subscriber;->request(J)V
return-void
.end method
# virtual methods
.method public call()V
.registers 16
.line 1
iget-wide v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->emitted:J
.line 2
iget-object v2, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->queue:Ljava/util/Queue;
.line 3
iget-object v3, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->child:Lrx/Subscriber;
const-wide/16 v4, 0x1
move-wide v6, v0
move-wide v0, v4
.line 4
:cond_a
iget-object v8, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->requested:Ljava/util/concurrent/atomic/AtomicLong;
invoke-virtual {v8}, Ljava/util/concurrent/atomic/AtomicLong;->get()J
move-result-wide v8
:cond_10
:goto_10
const-wide/16 v10, 0x0
cmp-long v12, v8, v6
if-eqz v12, :cond_45
.line 5
iget-boolean v12, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->finished:Z
.line 6
invoke-interface {v2}, Ljava/util/Queue;->poll()Ljava/lang/Object;
move-result-object v13
if-nez v13, :cond_20
const/4 v14, 0x1
goto :goto_21
:cond_20
const/4 v14, 0x0
.line 7
:goto_21
invoke-virtual {p0, v12, v14, v3, v2}, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->checkTerminated(ZZLrx/Subscriber;Ljava/util/Queue;)Z
move-result v12
if-eqz v12, :cond_28
return-void
:cond_28
if-eqz v14, :cond_2b
goto :goto_45
.line 8
:cond_2b
invoke-static {v13}, Lrx/internal/operators/NotificationLite;->getValue(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v12
invoke-interface {v3, v12}, Lrx/Observer;->onNext(Ljava/lang/Object;)V
add-long/2addr v6, v4
.line 9
iget v12, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->limit:I
int-to-long v12, v12
cmp-long v14, v6, v12
if-nez v14, :cond_10
.line 10
iget-object v8, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->requested:Ljava/util/concurrent/atomic/AtomicLong;
invoke-static {v8, v6, v7}, Lrx/internal/operators/BackpressureUtils;->produced(Ljava/util/concurrent/atomic/AtomicLong;J)J
move-result-wide v8
.line 11
invoke-virtual {p0, v6, v7}, Lrx/Subscriber;->request(J)V
move-wide v6, v10
goto :goto_10
:cond_45
:goto_45
cmp-long v12, v8, v6
if-nez v12, :cond_56
.line 12
iget-boolean v8, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->finished:Z
invoke-interface {v2}, Ljava/util/Queue;->isEmpty()Z
move-result v9
invoke-virtual {p0, v8, v9, v3, v2}, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->checkTerminated(ZZLrx/Subscriber;Ljava/util/Queue;)Z
move-result v8
if-eqz v8, :cond_56
return-void
.line 13
:cond_56
iput-wide v6, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->emitted:J
.line 14
iget-object v8, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->counter:Ljava/util/concurrent/atomic/AtomicLong;
neg-long v0, v0
invoke-virtual {v8, v0, v1}, Ljava/util/concurrent/atomic/AtomicLong;->addAndGet(J)J
move-result-wide v0
cmp-long v8, v0, v10
if-nez v8, :cond_a
return-void
.end method
.method checkTerminated(ZZLrx/Subscriber;Ljava/util/Queue;)Z
.registers 7
.annotation system Ldalvik/annotation/Signature;
value = {
"(ZZ",
"Lrx/Subscriber<",
"-TT;>;",
"Ljava/util/Queue<",
"Ljava/lang/Object;",
">;)Z"
}
.end annotation
.line 1
invoke-virtual {p3}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v0
const/4 v1, 0x1
if-eqz v0, :cond_b
.line 2
invoke-interface {p4}, Ljava/util/Queue;->clear()V
return v1
:cond_b
if-eqz p1, :cond_54
.line 3
iget-boolean p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->delayError:Z
if-eqz p1, :cond_2b
if-eqz p2, :cond_54
.line 4
iget-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->error:Ljava/lang/Throwable;
if-eqz p1, :cond_1b
.line 5
:try_start_17
invoke-interface {p3, p1}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
goto :goto_1e
.line 6
:cond_1b
invoke-interface {p3}, Lrx/Observer;->onCompleted()V
:try_end_1e
.catchall {:try_start_17 .. :try_end_1e} :catchall_24
.line 7
:goto_1e
iget-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-interface {p1}, Lrx/Subscription;->unsubscribe()V
goto :goto_54
:catchall_24
move-exception p1
iget-object p2, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-interface {p2}, Lrx/Subscription;->unsubscribe()V
throw p1
.line 8
:cond_2b
iget-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->error:Ljava/lang/Throwable;
if-eqz p1, :cond_42
.line 9
invoke-interface {p4}, Ljava/util/Queue;->clear()V
.line 10
:try_start_32
invoke-interface {p3, p1}, Lrx/Observer;->onError(Ljava/lang/Throwable;)V
:try_end_35
.catchall {:try_start_32 .. :try_end_35} :catchall_3b
.line 11
iget-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-interface {p1}, Lrx/Subscription;->unsubscribe()V
return v1
:catchall_3b
move-exception p1
iget-object p2, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-interface {p2}, Lrx/Subscription;->unsubscribe()V
throw p1
:cond_42
if-eqz p2, :cond_54
.line 12
:try_start_44
invoke-interface {p3}, Lrx/Observer;->onCompleted()V
:try_end_47
.catchall {:try_start_44 .. :try_end_47} :catchall_4d
.line 13
iget-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-interface {p1}, Lrx/Subscription;->unsubscribe()V
return v1
:catchall_4d
move-exception p1
iget-object p2, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-interface {p2}, Lrx/Subscription;->unsubscribe()V
throw p1
:cond_54
:goto_54
const/4 p1, 0x0
return p1
.end method
.method init()V
.registers 3
.line 1
iget-object v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->child:Lrx/Subscriber;
.line 2
new-instance v1, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber$1;
invoke-direct {v1, p0}, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber$1;-><init>(Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;)V
invoke-virtual {v0, v1}, Lrx/Subscriber;->setProducer(Lrx/Producer;)V
.line 3
iget-object v1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-virtual {v0, v1}, Lrx/Subscriber;->add(Lrx/Subscription;)V
.line 4
invoke-virtual {v0, p0}, Lrx/Subscriber;->add(Lrx/Subscription;)V
return-void
.end method
.method public onCompleted()V
.registers 2
.line 1
invoke-virtual {p0}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v0
if-nez v0, :cond_11
iget-boolean v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->finished:Z
if-eqz v0, :cond_b
goto :goto_11
:cond_b
const/4 v0, 0x1
.line 2
iput-boolean v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->finished:Z
.line 3
invoke-virtual {p0}, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->schedule()V
:cond_11
:goto_11
return-void
.end method
.method public onError(Ljava/lang/Throwable;)V
.registers 3
.line 1
invoke-virtual {p0}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v0
if-nez v0, :cond_14
iget-boolean v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->finished:Z
if-eqz v0, :cond_b
goto :goto_14
.line 2
:cond_b
iput-object p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->error:Ljava/lang/Throwable;
const/4 p1, 0x1
.line 3
iput-boolean p1, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->finished:Z
.line 4
invoke-virtual {p0}, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->schedule()V
return-void
.line 5
:cond_14
:goto_14
invoke-static {p1}, Lrx/plugins/RxJavaHooks;->onError(Ljava/lang/Throwable;)V
return-void
.end method
.method public onNext(Ljava/lang/Object;)V
.registers 3
.annotation system Ldalvik/annotation/Signature;
value = {
"(TT;)V"
}
.end annotation
.line 1
invoke-virtual {p0}, Lrx/Subscriber;->isUnsubscribed()Z
move-result v0
if-nez v0, :cond_23
iget-boolean v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->finished:Z
if-eqz v0, :cond_b
goto :goto_23
.line 2
:cond_b
iget-object v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->queue:Ljava/util/Queue;
invoke-static {p1}, Lrx/internal/operators/NotificationLite;->next(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p1
invoke-interface {v0, p1}, Ljava/util/Queue;->offer(Ljava/lang/Object;)Z
move-result p1
if-nez p1, :cond_20
.line 3
new-instance p1, Lrx/exceptions/MissingBackpressureException;
invoke-direct {p1}, Lrx/exceptions/MissingBackpressureException;-><init>()V
invoke-virtual {p0, p1}, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->onError(Ljava/lang/Throwable;)V
return-void
.line 4
:cond_20
invoke-virtual {p0}, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->schedule()V
:cond_23
:goto_23
return-void
.end method
.method protected schedule()V
.registers 6
.line 1
iget-object v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->counter:Ljava/util/concurrent/atomic/AtomicLong;
invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicLong;->getAndIncrement()J
move-result-wide v0
const-wide/16 v2, 0x0
cmp-long v4, v0, v2
if-nez v4, :cond_11
.line 2
iget-object v0, p0, Lrx/internal/operators/OperatorObserveOn$ObserveOnSubscriber;->recursiveScheduler:Lrx/Scheduler$Worker;
invoke-virtual {v0, p0}, Lrx/Scheduler$Worker;->schedule(Lrx/functions/Action0;)Lrx/Subscription;
:cond_11
return-void
.end method