144 lines
4.2 KiB
Java
144 lines
4.2 KiB
Java
package j0.n;
|
|
|
|
import j0.g;
|
|
import j0.l.a.e;
|
|
import rx.exceptions.OnErrorThrowable;
|
|
/* compiled from: SerializedObserver */
|
|
public class c<T> implements g<T> {
|
|
public final g<? super T> i;
|
|
public boolean j;
|
|
public volatile boolean k;
|
|
public a l;
|
|
|
|
/* compiled from: SerializedObserver */
|
|
public static final class a {
|
|
public Object[] a;
|
|
public int b;
|
|
|
|
public void a(Object obj) {
|
|
int i = this.b;
|
|
Object[] objArr = this.a;
|
|
if (objArr == null) {
|
|
objArr = new Object[16];
|
|
this.a = objArr;
|
|
} else if (i == objArr.length) {
|
|
Object[] objArr2 = new Object[((i >> 2) + i)];
|
|
System.arraycopy(objArr, 0, objArr2, 0, i);
|
|
this.a = objArr2;
|
|
objArr = objArr2;
|
|
}
|
|
objArr[i] = obj;
|
|
this.b = i + 1;
|
|
}
|
|
}
|
|
|
|
public c(g<? super T> gVar) {
|
|
this.i = gVar;
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
if (!this.k) {
|
|
synchronized (this) {
|
|
if (!this.k) {
|
|
this.k = true;
|
|
if (this.j) {
|
|
a aVar = this.l;
|
|
if (aVar == null) {
|
|
aVar = new a();
|
|
this.l = aVar;
|
|
}
|
|
aVar.a(e.a);
|
|
return;
|
|
}
|
|
this.j = true;
|
|
this.i.onCompleted();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
c.q.a.k.a.a0(th);
|
|
if (!this.k) {
|
|
synchronized (this) {
|
|
if (!this.k) {
|
|
this.k = true;
|
|
if (this.j) {
|
|
a aVar = this.l;
|
|
if (aVar == null) {
|
|
aVar = new a();
|
|
this.l = aVar;
|
|
}
|
|
aVar.a(new e.c(th));
|
|
return;
|
|
}
|
|
this.j = true;
|
|
this.i.onError(th);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
a aVar;
|
|
int i;
|
|
if (!this.k) {
|
|
synchronized (this) {
|
|
if (!this.k) {
|
|
if (this.j) {
|
|
a aVar2 = this.l;
|
|
if (aVar2 == null) {
|
|
aVar2 = new a();
|
|
this.l = aVar2;
|
|
}
|
|
if (t == null) {
|
|
t = (T) e.b;
|
|
}
|
|
aVar2.a(t);
|
|
return;
|
|
}
|
|
this.j = true;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
try {
|
|
this.i.onNext(t);
|
|
while (true) {
|
|
synchronized (this) {
|
|
aVar = this.l;
|
|
if (aVar == null) {
|
|
this.j = false;
|
|
return;
|
|
}
|
|
this.l = null;
|
|
}
|
|
Object[] objArr = aVar.a;
|
|
for (Object obj : objArr) {
|
|
if (obj == null) {
|
|
continue;
|
|
break;
|
|
}
|
|
try {
|
|
if (e.a(this.i, obj)) {
|
|
this.k = true;
|
|
return;
|
|
}
|
|
} catch (Throwable th) {
|
|
this.k = true;
|
|
c.q.a.k.a.a0(th);
|
|
this.i.onError(OnErrorThrowable.a(th, t));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} catch (Throwable th2) {
|
|
this.k = true;
|
|
c.q.a.k.a.b0(th2, this.i, t);
|
|
}
|
|
}
|
|
}
|
|
}
|