package j0.l.a; import j0.o.l; import rx.Subscriber; /* compiled from: DeferredScalarSubscriberSafe */ public abstract class b extends a { public boolean m; public b(Subscriber subscriber) { super(subscriber); } @Override // j0.g public void onCompleted() { if (!this.m) { this.m = true; if (this.j) { R r = this.k; Subscriber subscriber = this.i; do { int i = this.l.get(); if (i != 2 && i != 3 && !subscriber.isUnsubscribed()) { if (i == 1) { subscriber.onNext(r); if (!subscriber.isUnsubscribed()) { subscriber.onCompleted(); } this.l.lazySet(3); return; } this.k = r; } else { return; } } while (!this.l.compareAndSet(0, 2)); return; } this.i.onCompleted(); } } @Override // j0.g public void onError(Throwable th) { if (!this.m) { this.m = true; this.k = null; this.i.onError(th); return; } l.b(th); } }