SubjectSubscriptionManager.smali

.class public final Lrx/subjects/SubjectSubscriptionManager;
.super Ljava/util/concurrent/atomic/AtomicReference;
.source "SubjectSubscriptionManager.java"

# interfaces
.implements Lrx/f;


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Ljava/lang/Object;",
        ">",
        "Ljava/util/concurrent/atomic/AtomicReference",
        "<",
        "Lrx/subjects/c",
        "<TT;>;>;",
        "Lrx/f",
        "<TT;>;"
    }
.end annotation


# static fields
.field private static final serialVersionUID:J = 0x53c184d753c8b010L


# instance fields
.field active:Z

.field volatile latest:Ljava/lang/Object;

.field public onAdded:Lrx/b/b;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lrx/b/b",
            "<",
            "Lrx/subjects/d",
            "<TT;>;>;"
        }
    .end annotation
.end field

.field onStart:Lrx/b/b;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lrx/b/b",
            "<",
            "Lrx/subjects/d",
            "<TT;>;>;"
        }
    .end annotation
.end field

.field public onTerminated:Lrx/b/b;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lrx/b/b",
            "<",
            "Lrx/subjects/d",
            "<TT;>;>;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>()V
    .registers 2

    .prologue
    .line 51
    sget-object v0, Lrx/subjects/c;->cdu:Lrx/subjects/c;

    invoke-direct {p0, v0}, Ljava/util/concurrent/atomic/AtomicReference;-><init>(Ljava/lang/Object;)V

    .line 42
    const/4 v0, 0x1

    iput-boolean v0, p0, Lrx/subjects/SubjectSubscriptionManager;->active:Z

    .line 44
    invoke-static {}, Lrx/b/c;->SP()Lrx/b/d;

    move-result-object v0

    iput-object v0, p0, Lrx/subjects/SubjectSubscriptionManager;->onStart:Lrx/b/b;

    .line 46
    invoke-static {}, Lrx/b/c;->SP()Lrx/b/d;

    move-result-object v0

    iput-object v0, p0, Lrx/subjects/SubjectSubscriptionManager;->onAdded:Lrx/b/b;

    .line 48
    invoke-static {}, Lrx/b/c;->SP()Lrx/b/d;

    move-result-object v0

    iput-object v0, p0, Lrx/subjects/SubjectSubscriptionManager;->onTerminated:Lrx/b/b;

    .line 52
    return-void
.end method


# virtual methods
.method final add(Lrx/subjects/d;)Z
    .registers 7
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lrx/subjects/d",
            "<TT;>;)Z"
        }
    .end annotation

    .prologue
    const/4 v1, 0x0

    .line 93
    :cond_1
    invoke-virtual {p0}, Lrx/subjects/SubjectSubscriptionManager;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lrx/subjects/c;

    .line 94
    iget-boolean v2, v0, Lrx/subjects/c;->terminated:Z

    if-eqz v2, :cond_12

    .line 95
    iget-object v0, p0, Lrx/subjects/SubjectSubscriptionManager;->onTerminated:Lrx/b/b;

    invoke-interface {v0, p1}, Lrx/b/b;->call(Ljava/lang/Object;)V

    move v0, v1

    .line 101
    :goto_11
    return v0

    .line 1160
    :cond_12
    iget-object v2, v0, Lrx/subjects/c;->cdr:[Lrx/subjects/d;

    .line 1161
    array-length v2, v2

    .line 1162
    add-int/lit8 v3, v2, 0x1

    new-array v3, v3, [Lrx/subjects/d;

    .line 1163
    iget-object v4, v0, Lrx/subjects/c;->cdr:[Lrx/subjects/d;

    invoke-static {v4, v1, v3, v1, v2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 1164
    aput-object p1, v3, v2

    .line 1165
    new-instance v2, Lrx/subjects/c;

    iget-boolean v4, v0, Lrx/subjects/c;->terminated:Z

    invoke-direct {v2, v4, v3}, Lrx/subjects/c;-><init>(Z[Lrx/subjects/d;)V

    .line 99
    invoke-virtual {p0, v0, v2}, Lrx/subjects/SubjectSubscriptionManager;->compareAndSet(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 100
    iget-object v0, p0, Lrx/subjects/SubjectSubscriptionManager;->onAdded:Lrx/b/b;

    invoke-interface {v0, p1}, Lrx/b/b;->call(Ljava/lang/Object;)V

    .line 101
    const/4 v0, 0x1

    goto :goto_11
.end method

.method final addUnsubscriber(Lrx/o;Lrx/subjects/d;)V
    .registers 4
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lrx/o",
            "<-TT;>;",
            "Lrx/subjects/d",
            "<TT;>;)V"
        }
    .end annotation

    .prologue
    .line 67
    new-instance v0, Lrx/subjects/SubjectSubscriptionManager$1;

    invoke-direct {v0, p0, p2}, Lrx/subjects/SubjectSubscriptionManager$1;-><init>(Lrx/subjects/SubjectSubscriptionManager;Lrx/subjects/d;)V

    invoke-static {v0}, Lrx/g/e;->g(Lrx/b/a;)Lrx/p;

    move-result-object v0

    invoke-virtual {p1, v0}, Lrx/o;->add(Lrx/p;)V

    .line 73
    return-void
.end method

.method public final bridge synthetic call(Ljava/lang/Object;)V
    .registers 2

    .prologue
    .line 35
    check-cast p1, Lrx/o;

    invoke-virtual {p0, p1}, Lrx/subjects/SubjectSubscriptionManager;->call(Lrx/o;)V

    return-void
.end method

.method public final call(Lrx/o;)V
    .registers 4
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lrx/o",
            "<-TT;>;)V"
        }
    .end annotation

    .prologue
    .line 56
    new-instance v0, Lrx/subjects/d;

    invoke-direct {v0, p1}, Lrx/subjects/d;-><init>(Lrx/o;)V

    .line 57
    invoke-virtual {p0, p1, v0}, Lrx/subjects/SubjectSubscriptionManager;->addUnsubscriber(Lrx/o;Lrx/subjects/d;)V

    .line 58
    iget-object v1, p0, Lrx/subjects/SubjectSubscriptionManager;->onStart:Lrx/b/b;

    invoke-interface {v1, v0}, Lrx/b/b;->call(Ljava/lang/Object;)V

    .line 59
    invoke-virtual {p1}, Lrx/o;->isUnsubscribed()Z

    move-result v1

    if-nez v1, :cond_22

    .line 60
    invoke-virtual {p0, v0}, Lrx/subjects/SubjectSubscriptionManager;->add(Lrx/subjects/d;)Z

    move-result v1

    if-eqz v1, :cond_22

    invoke-virtual {p1}, Lrx/o;->isUnsubscribed()Z

    move-result v1

    if-eqz v1, :cond_22

    .line 61
    invoke-virtual {p0, v0}, Lrx/subjects/SubjectSubscriptionManager;->remove(Lrx/subjects/d;)V

    .line 64
    :cond_22
    return-void
.end method

.method final getLatest()Ljava/lang/Object;
    .registers 2

    .prologue
    .line 80
    iget-object v0, p0, Lrx/subjects/SubjectSubscriptionManager;->latest:Ljava/lang/Object;

    return-object v0
.end method

.method final next(Ljava/lang/Object;)[Lrx/subjects/d;
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/Object;",
            ")[",
            "Lrx/subjects/d",
            "<TT;>;"
        }
    .end annotation

    .prologue
    .line 127
    invoke-virtual {p0, p1}, Lrx/subjects/SubjectSubscriptionManager;->setLatest(Ljava/lang/Object;)V

    .line 128
    invoke-virtual {p0}, Lrx/subjects/SubjectSubscriptionManager;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lrx/subjects/c;

    iget-object v0, v0, Lrx/subjects/c;->cdr:[Lrx/subjects/d;

    return-object v0
.end method

.method final observers()[Lrx/subjects/d;
    .registers 2
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()[",
            "Lrx/subjects/d",
            "<TT;>;"
        }
    .end annotation

    .prologue
    .line 84
    invoke-virtual {p0}, Lrx/subjects/SubjectSubscriptionManager;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lrx/subjects/c;

    iget-object v0, v0, Lrx/subjects/c;->cdr:[Lrx/subjects/d;

    return-object v0
.end method

.method final remove(Lrx/subjects/d;)V
    .registers 11
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lrx/subjects/d",
            "<TT;>;)V"
        }
    .end annotation

    .prologue
    const/4 v5, 0x0

    .line 111
    :cond_1
    invoke-virtual {p0}, Lrx/subjects/SubjectSubscriptionManager;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lrx/subjects/c;

    .line 112
    iget-boolean v1, v0, Lrx/subjects/c;->terminated:Z

    if-eqz v1, :cond_c

    .line 117
    :cond_b
    :goto_b
    return-void

    .line 1168
    :cond_c
    iget-object v6, v0, Lrx/subjects/c;->cdr:[Lrx/subjects/d;

    .line 1169
    array-length v7, v6

    .line 1170
    const/4 v1, 0x1

    if-ne v7, v1, :cond_21

    aget-object v1, v6, v5

    if-ne v1, p1, :cond_21

    .line 1171
    sget-object v1, Lrx/subjects/c;->cdu:Lrx/subjects/c;

    .line 116
    :goto_18
    if-eq v1, v0, :cond_b

    invoke-virtual {p0, v0, v1}, Lrx/subjects/SubjectSubscriptionManager;->compareAndSet(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_1

    goto :goto_b

    .line 1173
    :cond_21
    if-nez v7, :cond_25

    move-object v1, v0

    .line 1174
    goto :goto_18

    .line 1176
    :cond_25
    add-int/lit8 v1, v7, -0x1

    new-array v3, v1, [Lrx/subjects/d;

    move v4, v5

    move v2, v5

    .line 1178
    :goto_2b
    if-ge v4, v7, :cond_40

    .line 1179
    aget-object v8, v6, v4

    .line 1180
    if-eq v8, p1, :cond_59

    .line 1181
    add-int/lit8 v1, v7, -0x1

    if-ne v2, v1, :cond_37

    move-object v1, v0

    .line 1182
    goto :goto_18

    .line 1184
    :cond_37
    add-int/lit8 v1, v2, 0x1

    aput-object v8, v3, v2

    .line 1178
    :goto_3b
    add-int/lit8 v2, v4, 0x1

    move v4, v2

    move v2, v1

    goto :goto_2b

    .line 1187
    :cond_40
    if-nez v2, :cond_45

    .line 1188
    sget-object v1, Lrx/subjects/c;->cdu:Lrx/subjects/c;

    goto :goto_18

    .line 1190
    :cond_45
    add-int/lit8 v1, v7, -0x1

    if-ge v2, v1, :cond_57

    .line 1191
    new-array v1, v2, [Lrx/subjects/d;

    .line 1192
    invoke-static {v3, v5, v1, v5, v2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 1195
    :goto_4e
    new-instance v2, Lrx/subjects/c;

    iget-boolean v3, v0, Lrx/subjects/c;->terminated:Z

    invoke-direct {v2, v3, v1}, Lrx/subjects/c;-><init>(Z[Lrx/subjects/d;)V

    move-object v1, v2

    goto :goto_18

    :cond_57
    move-object v1, v3

    goto :goto_4e

    :cond_59
    move v1, v2

    goto :goto_3b
.end method

.method final setLatest(Ljava/lang/Object;)V
    .registers 2

    .prologue
    .line 76
    iput-object p1, p0, Lrx/subjects/SubjectSubscriptionManager;->latest:Ljava/lang/Object;

    .line 77
    return-void
.end method

.method final terminate(Ljava/lang/Object;)[Lrx/subjects/d;
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/Object;",
            ")[",
            "Lrx/subjects/d",
            "<TT;>;"
        }
    .end annotation

    .prologue
    .line 137
    invoke-virtual {p0, p1}, Lrx/subjects/SubjectSubscriptionManager;->setLatest(Ljava/lang/Object;)V

    .line 138
    const/4 v0, 0x0

    iput-boolean v0, p0, Lrx/subjects/SubjectSubscriptionManager;->active:Z

    .line 140
    invoke-virtual {p0}, Lrx/subjects/SubjectSubscriptionManager;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lrx/subjects/c;

    .line 141
    iget-boolean v0, v0, Lrx/subjects/c;->terminated:Z

    if-eqz v0, :cond_13

    .line 142
    sget-object v0, Lrx/subjects/c;->cds:[Lrx/subjects/d;

    .line 144
    :goto_12
    return-object v0

    :cond_13
    sget-object v0, Lrx/subjects/c;->cdt:Lrx/subjects/c;

    invoke-virtual {p0, v0}, Lrx/subjects/SubjectSubscriptionManager;->getAndSet(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lrx/subjects/c;

    iget-object v0, v0, Lrx/subjects/c;->cdr:[Lrx/subjects/d;

    goto :goto_12
.end method