c.smali

.class public final Lio/reactivex/processors/c;
.super Lio/reactivex/processors/a;
.source "SourceFile"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lio/reactivex/processors/c$a;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Ljava/lang/Object;",
        ">",
        "Lio/reactivex/processors/a<",
        "TT;>;"
    }
.end annotation


# instance fields
.field public final b:Lio/reactivex/internal/queue/c;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lio/reactivex/internal/queue/c<",
            "TT;>;"
        }
    .end annotation
.end field

.field public final c:Ljava/util/concurrent/atomic/AtomicReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/concurrent/atomic/AtomicReference<",
            "Ljava/lang/Runnable;",
            ">;"
        }
    .end annotation
.end field

.field public final d:Z

.field public volatile e:Z

.field public f:Ljava/lang/Throwable;

.field public final g:Ljava/util/concurrent/atomic/AtomicReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/concurrent/atomic/AtomicReference<",
            "Lorg/reactivestreams/b<",
            "-TT;>;>;"
        }
    .end annotation
.end field

.field public volatile h:Z

.field public final i:Ljava/util/concurrent/atomic/AtomicBoolean;

.field public final j:Lio/reactivex/processors/c$a;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lio/reactivex/internal/subscriptions/a<",
            "TT;>;"
        }
    .end annotation
.end field

.field public final k:Ljava/util/concurrent/atomic/AtomicLong;

.field public l:Z


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

    .line 1
    invoke-direct {p0}, Lio/reactivex/processors/a;-><init>()V

    .line 2
    new-instance v0, Lio/reactivex/internal/queue/c;

    const/16 v1, 0x8

    const-string v2, "capacityHint"

    invoke-static {v1, v2}, Lio/reactivex/internal/functions/b;->b(ILjava/lang/String;)I

    invoke-direct {v0, v1}, Lio/reactivex/internal/queue/c;-><init>(I)V

    iput-object v0, p0, Lio/reactivex/processors/c;->b:Lio/reactivex/internal/queue/c;

    .line 3
    new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;

    const/4 v1, 0x0

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

    iput-object v0, p0, Lio/reactivex/processors/c;->c:Ljava/util/concurrent/atomic/AtomicReference;

    const/4 v0, 0x1

    .line 4
    iput-boolean v0, p0, Lio/reactivex/processors/c;->d:Z

    .line 5
    new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;

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

    iput-object v0, p0, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    .line 6
    new-instance v0, Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>()V

    iput-object v0, p0, Lio/reactivex/processors/c;->i:Ljava/util/concurrent/atomic/AtomicBoolean;

    .line 7
    new-instance v0, Lio/reactivex/processors/c$a;

    invoke-direct {v0, p0}, Lio/reactivex/processors/c$a;-><init>(Lio/reactivex/processors/c;)V

    iput-object v0, p0, Lio/reactivex/processors/c;->j:Lio/reactivex/processors/c$a;

    .line 8
    new-instance v0, Ljava/util/concurrent/atomic/AtomicLong;

    invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicLong;-><init>()V

    iput-object v0, p0, Lio/reactivex/processors/c;->k:Ljava/util/concurrent/atomic/AtomicLong;

    return-void
.end method


# virtual methods
.method public final k(Lorg/reactivestreams/b;)V
    .registers 5
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lorg/reactivestreams/b<",
            "-TT;>;)V"
        }
    .end annotation

    .line 1
    iget-object v0, p0, Lio/reactivex/processors/c;->i:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v0

    if-nez v0, :cond_2b

    iget-object v0, p0, Lio/reactivex/processors/c;->i:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x0

    const/4 v2, 0x1

    invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v0

    if-eqz v0, :cond_2b

    .line 2
    iget-object v0, p0, Lio/reactivex/processors/c;->j:Lio/reactivex/processors/c$a;

    invoke-interface {p1, v0}, Lorg/reactivestreams/b;->onSubscribe(Lorg/reactivestreams/c;)V

    .line 3
    iget-object v0, p0, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {v0, p1}, Ljava/util/concurrent/atomic/AtomicReference;->set(Ljava/lang/Object;)V

    .line 4
    iget-boolean p1, p0, Lio/reactivex/processors/c;->h:Z

    if-eqz p1, :cond_27

    .line 5
    iget-object p1, p0, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    const/4 v0, 0x0

    invoke-virtual {p1, v0}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V

    goto :goto_35

    .line 6
    :cond_27
    invoke-virtual {p0}, Lio/reactivex/processors/c;->o()V

    goto :goto_35

    .line 7
    :cond_2b
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "This processor allows only a single Subscriber"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    invoke-static {v0, p1}, Lio/reactivex/internal/subscriptions/c;->error(Ljava/lang/Throwable;Lorg/reactivestreams/b;)V

    :goto_35
    return-void
.end method

.method public final m(ZZZLorg/reactivestreams/b;Lio/reactivex/internal/queue/c;)Z
    .registers 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(ZZZ",
            "Lorg/reactivestreams/b<",
            "-TT;>;",
            "Lio/reactivex/internal/queue/c<",
            "TT;>;)Z"
        }
    .end annotation

    .line 1
    iget-boolean v0, p0, Lio/reactivex/processors/c;->h:Z

    const/4 v1, 0x1

    const/4 v2, 0x0

    if-eqz v0, :cond_f

    .line 2
    invoke-virtual {p5}, Lio/reactivex/internal/queue/c;->clear()V

    .line 3
    iget-object p1, p0, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {p1, v2}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V

    return v1

    :cond_f
    if-eqz p2, :cond_38

    if-eqz p1, :cond_25

    .line 4
    iget-object p1, p0, Lio/reactivex/processors/c;->f:Ljava/lang/Throwable;

    if-eqz p1, :cond_25

    .line 5
    invoke-virtual {p5}, Lio/reactivex/internal/queue/c;->clear()V

    .line 6
    iget-object p1, p0, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {p1, v2}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V

    .line 7
    iget-object p1, p0, Lio/reactivex/processors/c;->f:Ljava/lang/Throwable;

    invoke-interface {p4, p1}, Lorg/reactivestreams/b;->onError(Ljava/lang/Throwable;)V

    return v1

    :cond_25
    if-eqz p3, :cond_38

    .line 8
    iget-object p1, p0, Lio/reactivex/processors/c;->f:Ljava/lang/Throwable;

    .line 9
    iget-object p2, p0, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {p2, v2}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V

    if-eqz p1, :cond_34

    .line 10
    invoke-interface {p4, p1}, Lorg/reactivestreams/b;->onError(Ljava/lang/Throwable;)V

    goto :goto_37

    .line 11
    :cond_34
    invoke-interface {p4}, Lorg/reactivestreams/b;->onComplete()V

    :goto_37
    return v1

    :cond_38
    const/4 p1, 0x0

    return p1
.end method

.method public final n()V
    .registers 4

    .line 1
    iget-object v0, p0, Lio/reactivex/processors/c;->c:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Runnable;

    if-eqz v0, :cond_16

    .line 2
    iget-object v1, p0, Lio/reactivex/processors/c;->c:Ljava/util/concurrent/atomic/AtomicReference;

    const/4 v2, 0x0

    invoke-virtual {v1, v0, v2}, Ljava/util/concurrent/atomic/AtomicReference;->compareAndSet(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_16

    .line 3
    invoke-interface {v0}, Ljava/lang/Runnable;->run()V

    :cond_16
    return-void
.end method

.method public final o()V
    .registers 19

    move-object/from16 v6, p0

    .line 1
    iget-object v0, v6, Lio/reactivex/processors/c;->j:Lio/reactivex/processors/c$a;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicInteger;->getAndIncrement()I

    move-result v0

    if-eqz v0, :cond_b

    return-void

    .line 2
    :cond_b
    iget-object v0, v6, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/reactivestreams/b;

    const/4 v7, 0x1

    move-object v8, v0

    const/4 v0, 0x1

    :goto_16
    if-eqz v8, :cond_df

    .line 3
    iget-boolean v0, v6, Lio/reactivex/processors/c;->l:Z

    if-eqz v0, :cond_6c

    .line 4
    iget-object v0, v6, Lio/reactivex/processors/c;->b:Lio/reactivex/internal/queue/c;

    .line 5
    iget-boolean v1, v6, Lio/reactivex/processors/c;->d:Z

    xor-int/2addr v1, v7

    .line 6
    :cond_21
    iget-boolean v2, v6, Lio/reactivex/processors/c;->h:Z

    const/4 v3, 0x0

    if-eqz v2, :cond_30

    .line 7
    invoke-virtual {v0}, Lio/reactivex/internal/queue/c;->clear()V

    .line 8
    iget-object v0, v6, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {v0, v3}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V

    goto/16 :goto_dc

    .line 9
    :cond_30
    iget-boolean v2, v6, Lio/reactivex/processors/c;->e:Z

    if-eqz v1, :cond_49

    if-eqz v2, :cond_49

    .line 10
    iget-object v4, v6, Lio/reactivex/processors/c;->f:Ljava/lang/Throwable;

    if-eqz v4, :cond_49

    .line 11
    invoke-virtual {v0}, Lio/reactivex/internal/queue/c;->clear()V

    .line 12
    iget-object v0, v6, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {v0, v3}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V

    .line 13
    iget-object v0, v6, Lio/reactivex/processors/c;->f:Ljava/lang/Throwable;

    invoke-interface {v8, v0}, Lorg/reactivestreams/b;->onError(Ljava/lang/Throwable;)V

    goto/16 :goto_dc

    .line 14
    :cond_49
    invoke-interface {v8, v3}, Lorg/reactivestreams/b;->onNext(Ljava/lang/Object;)V

    if-eqz v2, :cond_61

    .line 15
    iget-object v0, v6, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {v0, v3}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V

    .line 16
    iget-object v0, v6, Lio/reactivex/processors/c;->f:Ljava/lang/Throwable;

    if-eqz v0, :cond_5c

    .line 17
    invoke-interface {v8, v0}, Lorg/reactivestreams/b;->onError(Ljava/lang/Throwable;)V

    goto/16 :goto_dc

    .line 18
    :cond_5c
    invoke-interface {v8}, Lorg/reactivestreams/b;->onComplete()V

    goto/16 :goto_dc

    .line 19
    :cond_61
    iget-object v2, v6, Lio/reactivex/processors/c;->j:Lio/reactivex/processors/c$a;

    neg-int v3, v7

    invoke-virtual {v2, v3}, Ljava/util/concurrent/atomic/AtomicInteger;->addAndGet(I)I

    move-result v7

    if-nez v7, :cond_21

    goto/16 :goto_dc

    .line 20
    :cond_6c
    iget-object v9, v6, Lio/reactivex/processors/c;->b:Lio/reactivex/internal/queue/c;

    .line 21
    iget-boolean v0, v6, Lio/reactivex/processors/c;->d:Z

    xor-int/lit8 v10, v0, 0x1

    const/4 v11, 0x1

    .line 22
    :goto_73
    iget-object v0, v6, Lio/reactivex/processors/c;->k:Ljava/util/concurrent/atomic/AtomicLong;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicLong;->get()J

    move-result-wide v12

    const-wide/16 v4, 0x0

    :goto_7b
    cmp-long v16, v12, v4

    if-eqz v16, :cond_a9

    .line 23
    iget-boolean v2, v6, Lio/reactivex/processors/c;->e:Z

    .line 24
    invoke-virtual {v9}, Lio/reactivex/internal/queue/c;->poll()Ljava/lang/Object;

    move-result-object v3

    if-nez v3, :cond_8a

    const/16 v17, 0x1

    goto :goto_8d

    :cond_8a
    const/4 v0, 0x0

    const/16 v17, 0x0

    :goto_8d
    move-object/from16 v0, p0

    move v1, v10

    move-object v7, v3

    move/from16 v3, v17

    move-wide v14, v4

    move-object v4, v8

    move-object v5, v9

    .line 25
    invoke-virtual/range {v0 .. v5}, Lio/reactivex/processors/c;->m(ZZZLorg/reactivestreams/b;Lio/reactivex/internal/queue/c;)Z

    move-result v0

    if-eqz v0, :cond_9d

    goto :goto_dc

    :cond_9d
    if-eqz v17, :cond_a0

    goto :goto_aa

    .line 26
    :cond_a0
    invoke-interface {v8, v7}, Lorg/reactivestreams/b;->onNext(Ljava/lang/Object;)V

    const-wide/16 v0, 0x1

    add-long v4, v14, v0

    const/4 v7, 0x1

    goto :goto_7b

    :cond_a9
    move-wide v14, v4

    :goto_aa
    if-nez v16, :cond_be

    .line 27
    iget-boolean v2, v6, Lio/reactivex/processors/c;->e:Z

    invoke-virtual {v9}, Lio/reactivex/internal/queue/c;->isEmpty()Z

    move-result v3

    move-object/from16 v0, p0

    move v1, v10

    move-object v4, v8

    move-object v5, v9

    invoke-virtual/range {v0 .. v5}, Lio/reactivex/processors/c;->m(ZZZLorg/reactivestreams/b;Lio/reactivex/internal/queue/c;)Z

    move-result v0

    if-eqz v0, :cond_be

    goto :goto_dc

    :cond_be
    const-wide/16 v0, 0x0

    cmp-long v2, v14, v0

    if-eqz v2, :cond_d3

    const-wide v0, 0x7fffffffffffffffL

    cmp-long v2, v12, v0

    if-eqz v2, :cond_d3

    .line 28
    iget-object v0, v6, Lio/reactivex/processors/c;->k:Ljava/util/concurrent/atomic/AtomicLong;

    neg-long v1, v14

    invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/atomic/AtomicLong;->addAndGet(J)J

    .line 29
    :cond_d3
    iget-object v0, v6, Lio/reactivex/processors/c;->j:Lio/reactivex/processors/c$a;

    neg-int v1, v11

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicInteger;->addAndGet(I)I

    move-result v11

    if-nez v11, :cond_dd

    :goto_dc
    return-void

    :cond_dd
    const/4 v7, 0x1

    goto :goto_73

    .line 30
    :cond_df
    iget-object v1, v6, Lio/reactivex/processors/c;->j:Lio/reactivex/processors/c$a;

    neg-int v0, v0

    invoke-virtual {v1, v0}, Ljava/util/concurrent/atomic/AtomicInteger;->addAndGet(I)I

    move-result v0

    if-nez v0, :cond_e9

    return-void

    .line 31
    :cond_e9
    iget-object v1, v6, Lio/reactivex/processors/c;->g:Ljava/util/concurrent/atomic/AtomicReference;

    invoke-virtual {v1}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;

    move-result-object v1

    move-object v8, v1

    check-cast v8, Lorg/reactivestreams/b;

    const/4 v7, 0x1

    goto/16 :goto_16
.end method

.method public final onComplete()V
    .registers 2

    .line 1
    iget-boolean v0, p0, Lio/reactivex/processors/c;->e:Z

    if-nez v0, :cond_12

    iget-boolean v0, p0, Lio/reactivex/processors/c;->h:Z

    if-eqz v0, :cond_9

    goto :goto_12

    :cond_9
    const/4 v0, 0x1

    .line 2
    iput-boolean v0, p0, Lio/reactivex/processors/c;->e:Z

    .line 3
    invoke-virtual {p0}, Lio/reactivex/processors/c;->n()V

    .line 4
    invoke-virtual {p0}, Lio/reactivex/processors/c;->o()V

    :cond_12
    :goto_12
    return-void
.end method

.method public final onError(Ljava/lang/Throwable;)V
    .registers 3

    const-string v0, "onError called with null. Null values are generally not allowed in 2.x operators and sources."

    .line 1
    invoke-static {p1, v0}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;

    .line 2
    iget-boolean v0, p0, Lio/reactivex/processors/c;->e:Z

    if-nez v0, :cond_1a

    iget-boolean v0, p0, Lio/reactivex/processors/c;->h:Z

    if-eqz v0, :cond_e

    goto :goto_1a

    .line 3
    :cond_e
    iput-object p1, p0, Lio/reactivex/processors/c;->f:Ljava/lang/Throwable;

    const/4 p1, 0x1

    .line 4
    iput-boolean p1, p0, Lio/reactivex/processors/c;->e:Z

    .line 5
    invoke-virtual {p0}, Lio/reactivex/processors/c;->n()V

    .line 6
    invoke-virtual {p0}, Lio/reactivex/processors/c;->o()V

    return-void

    .line 7
    :cond_1a
    :goto_1a
    invoke-static {p1}, Lio/reactivex/plugins/a;->b(Ljava/lang/Throwable;)V

    return-void
.end method

.method public final onNext(Ljava/lang/Object;)V
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(TT;)V"
        }
    .end annotation

    const-string v0, "onNext called with null. Null values are generally not allowed in 2.x operators and sources."

    .line 1
    invoke-static {p1, v0}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;

    .line 2
    iget-boolean v0, p0, Lio/reactivex/processors/c;->e:Z

    if-nez v0, :cond_16

    iget-boolean v0, p0, Lio/reactivex/processors/c;->h:Z

    if-eqz v0, :cond_e

    goto :goto_16

    .line 3
    :cond_e
    iget-object v0, p0, Lio/reactivex/processors/c;->b:Lio/reactivex/internal/queue/c;

    invoke-virtual {v0, p1}, Lio/reactivex/internal/queue/c;->offer(Ljava/lang/Object;)Z

    .line 4
    invoke-virtual {p0}, Lio/reactivex/processors/c;->o()V

    :cond_16
    :goto_16
    return-void
.end method

.method public final onSubscribe(Lorg/reactivestreams/c;)V
    .registers 4

    .line 1
    iget-boolean v0, p0, Lio/reactivex/processors/c;->e:Z

    if-nez v0, :cond_12

    iget-boolean v0, p0, Lio/reactivex/processors/c;->h:Z

    if-eqz v0, :cond_9

    goto :goto_12

    :cond_9
    const-wide v0, 0x7fffffffffffffffL

    .line 2
    invoke-interface {p1, v0, v1}, Lorg/reactivestreams/c;->request(J)V

    goto :goto_15

    .line 3
    :cond_12
    :goto_12
    invoke-interface {p1}, Lorg/reactivestreams/c;->cancel()V

    :goto_15
    return-void
.end method