discord-jadx/app/src/main/java/j0/l/e/h.java

105 lines
2.7 KiB
Java

package j0.l.e;
import c.d.b.a.a;
import j0.l.a.e;
import j0.l.e.m.c;
import j0.l.e.n.n;
import java.io.PrintStream;
import java.util.Queue;
import rx.Subscription;
import rx.exceptions.MissingBackpressureException;
/* compiled from: RxRingBuffer */
public class h implements Subscription {
public static final int i;
public Queue<Object> j;
public volatile Object k;
static {
int i2 = g.b ? 16 : 128;
String property = System.getProperty("rx.ring-buffer.size");
if (property != null) {
try {
i2 = Integer.parseInt(property);
} catch (NumberFormatException e) {
PrintStream printStream = System.err;
StringBuilder Q = a.Q("Failed to set 'rx.buffer.size' with value ", property, " => ");
Q.append(e.getMessage());
printStream.println(Q.toString());
}
}
i = i2;
}
public h() {
this.j = new c(i);
}
public h(boolean z2, int i2) {
this.j = z2 ? new j0.l.e.n.h<>(i2) : new n<>(i2);
}
public void a(Object obj) throws MissingBackpressureException {
boolean z2;
boolean z3;
synchronized (this) {
Queue<Object> queue = this.j;
z2 = true;
z3 = false;
if (queue != null) {
if (obj == null) {
obj = e.b;
}
z3 = !queue.offer(obj);
z2 = false;
}
}
if (z2) {
throw new IllegalStateException("This instance has been unsubscribed and the queue is no longer usable.");
} else if (z3) {
throw new MissingBackpressureException();
}
}
public Object b() {
synchronized (this) {
Queue<Object> queue = this.j;
if (queue == null) {
return null;
}
Object peek = queue.peek();
Object obj = this.k;
if (peek == null && obj != null && queue.peek() == null) {
peek = obj;
}
return peek;
}
}
public Object c() {
synchronized (this) {
Queue<Object> queue = this.j;
if (queue == null) {
return null;
}
Object poll = queue.poll();
Object obj = this.k;
if (poll == null && obj != null && queue.peek() == null) {
this.k = null;
poll = obj;
}
return poll;
}
}
@Override // rx.Subscription
public boolean isUnsubscribed() {
return this.j == null;
}
@Override // rx.Subscription
public void unsubscribe() {
synchronized (this) {
}
}
}