110 lines
3.4 KiB
Java
110 lines
3.4 KiB
Java
|
package j0.l.c;
|
||
|
|
||
|
import j0.r.c;
|
||
|
import java.util.concurrent.PriorityBlockingQueue;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||
|
import rx.Scheduler;
|
||
|
import rx.Subscription;
|
||
|
import rx.functions.Action0;
|
||
|
/* compiled from: TrampolineScheduler */
|
||
|
public final class m extends Scheduler {
|
||
|
public static final m a = new m();
|
||
|
|
||
|
/* compiled from: TrampolineScheduler */
|
||
|
public static final class a extends Scheduler.Worker implements Subscription {
|
||
|
public final AtomicInteger i = new AtomicInteger();
|
||
|
public final PriorityBlockingQueue<b> j = new PriorityBlockingQueue<>();
|
||
|
public final j0.r.a k = new j0.r.a();
|
||
|
public final AtomicInteger l = new AtomicInteger();
|
||
|
|
||
|
/* compiled from: TrampolineScheduler */
|
||
|
/* renamed from: j0.l.c.m$a$a reason: collision with other inner class name */
|
||
|
public class C0331a implements Action0 {
|
||
|
public final /* synthetic */ b i;
|
||
|
|
||
|
public C0331a(b bVar) {
|
||
|
this.i = bVar;
|
||
|
}
|
||
|
|
||
|
@Override // rx.functions.Action0
|
||
|
public void call() {
|
||
|
a.this.j.remove(this.i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // rx.Scheduler.Worker
|
||
|
public Subscription a(Action0 action0) {
|
||
|
return d(action0, System.currentTimeMillis());
|
||
|
}
|
||
|
|
||
|
@Override // rx.Scheduler.Worker
|
||
|
public Subscription b(Action0 action0, long j, TimeUnit timeUnit) {
|
||
|
long millis = timeUnit.toMillis(j) + System.currentTimeMillis();
|
||
|
return d(new l(action0, this, millis), millis);
|
||
|
}
|
||
|
|
||
|
public final Subscription d(Action0 action0, long j) {
|
||
|
if (this.k.isUnsubscribed()) {
|
||
|
return c.a;
|
||
|
}
|
||
|
b bVar = new b(action0, Long.valueOf(j), this.i.incrementAndGet());
|
||
|
this.j.add(bVar);
|
||
|
if (this.l.getAndIncrement() != 0) {
|
||
|
return new j0.r.a(new C0331a(bVar));
|
||
|
}
|
||
|
do {
|
||
|
b poll = this.j.poll();
|
||
|
if (poll != null) {
|
||
|
poll.i.call();
|
||
|
}
|
||
|
} while (this.l.decrementAndGet() > 0);
|
||
|
return c.a;
|
||
|
}
|
||
|
|
||
|
@Override // rx.Subscription
|
||
|
public boolean isUnsubscribed() {
|
||
|
return this.k.isUnsubscribed();
|
||
|
}
|
||
|
|
||
|
@Override // rx.Subscription
|
||
|
public void unsubscribe() {
|
||
|
this.k.unsubscribe();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: TrampolineScheduler */
|
||
|
public static final class b implements Comparable<b> {
|
||
|
public final Action0 i;
|
||
|
public final Long j;
|
||
|
public final int k;
|
||
|
|
||
|
public b(Action0 action0, Long l, int i) {
|
||
|
this.i = action0;
|
||
|
this.j = l;
|
||
|
this.k = i;
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
||
|
@Override // java.lang.Comparable
|
||
|
public int compareTo(b bVar) {
|
||
|
b bVar2 = bVar;
|
||
|
int compareTo = this.j.compareTo(bVar2.j);
|
||
|
if (compareTo != 0) {
|
||
|
return compareTo;
|
||
|
}
|
||
|
int i = this.k;
|
||
|
int i2 = bVar2.k;
|
||
|
if (i < i2) {
|
||
|
return -1;
|
||
|
}
|
||
|
return i == i2 ? 0 : 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // rx.Scheduler
|
||
|
public Scheduler.Worker a() {
|
||
|
return new a();
|
||
|
}
|
||
|
}
|