mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-12 17:07:17 +01:00
98 lines
4.4 KiB
Java
98 lines
4.4 KiB
Java
package rx;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import rx.annotations.Experimental;
|
|
import rx.functions.Action0;
|
|
import rx.functions.Func1;
|
|
import rx.internal.schedulers.SchedulerWhen;
|
|
import rx.subscriptions.MultipleAssignmentSubscription;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes12.dex */
|
|
public abstract class Scheduler {
|
|
static final long CLOCK_DRIFT_TOLERANCE_NANOS = TimeUnit.MINUTES.toNanos(Long.getLong("rx.scheduler.drift-tolerance", 15).longValue());
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static abstract class Worker implements Subscription {
|
|
public long now() {
|
|
return System.currentTimeMillis();
|
|
}
|
|
|
|
public abstract Subscription schedule(Action0 action0);
|
|
|
|
public abstract Subscription schedule(Action0 action0, long j, TimeUnit timeUnit);
|
|
|
|
public Subscription schedulePeriodically(Action0 action0, long j, long j2, TimeUnit timeUnit) {
|
|
long nanos = timeUnit.toNanos(j2);
|
|
long nanos2 = TimeUnit.MILLISECONDS.toNanos(now());
|
|
long nanos3 = timeUnit.toNanos(j) + nanos2;
|
|
MultipleAssignmentSubscription multipleAssignmentSubscription = new MultipleAssignmentSubscription();
|
|
Action0 action02 = new Action0(nanos2, nanos3, action0, multipleAssignmentSubscription, nanos) { // from class: rx.Scheduler.Worker.1
|
|
long count;
|
|
long lastNowNanos;
|
|
long startInNanos;
|
|
final /* synthetic */ Action0 val$action;
|
|
final /* synthetic */ long val$firstNowNanos;
|
|
final /* synthetic */ long val$firstStartInNanos;
|
|
final /* synthetic */ MultipleAssignmentSubscription val$mas;
|
|
final /* synthetic */ long val$periodInNanos;
|
|
|
|
{
|
|
this.val$firstNowNanos = nanos2;
|
|
this.val$firstStartInNanos = nanos3;
|
|
this.val$action = action0;
|
|
this.val$mas = multipleAssignmentSubscription;
|
|
this.val$periodInNanos = nanos;
|
|
this.lastNowNanos = nanos2;
|
|
this.startInNanos = nanos3;
|
|
}
|
|
|
|
@Override // rx.functions.Action0
|
|
public void call() {
|
|
long j3;
|
|
this.val$action.call();
|
|
if (this.val$mas.isUnsubscribed()) {
|
|
return;
|
|
}
|
|
long nanos4 = TimeUnit.MILLISECONDS.toNanos(Worker.this.now());
|
|
long j4 = Scheduler.CLOCK_DRIFT_TOLERANCE_NANOS;
|
|
long j5 = nanos4 + j4;
|
|
long j6 = this.lastNowNanos;
|
|
if (j5 >= j6) {
|
|
long j7 = this.val$periodInNanos;
|
|
if (nanos4 < j6 + j7 + j4) {
|
|
long j8 = this.startInNanos;
|
|
long j9 = this.count + 1;
|
|
this.count = j9;
|
|
j3 = (j9 * j7) + j8;
|
|
this.lastNowNanos = nanos4;
|
|
this.val$mas.set(Worker.this.schedule(this, j3 - nanos4, TimeUnit.NANOSECONDS));
|
|
}
|
|
}
|
|
long j10 = this.val$periodInNanos;
|
|
j3 = nanos4 + j10;
|
|
long j11 = this.count + 1;
|
|
this.count = j11;
|
|
this.startInNanos = j3 - (j10 * j11);
|
|
this.lastNowNanos = nanos4;
|
|
this.val$mas.set(Worker.this.schedule(this, j3 - nanos4, TimeUnit.NANOSECONDS));
|
|
}
|
|
};
|
|
MultipleAssignmentSubscription multipleAssignmentSubscription2 = new MultipleAssignmentSubscription();
|
|
multipleAssignmentSubscription.set(multipleAssignmentSubscription2);
|
|
multipleAssignmentSubscription2.set(schedule(action02, j, timeUnit));
|
|
return multipleAssignmentSubscription;
|
|
}
|
|
}
|
|
|
|
public abstract Worker createWorker();
|
|
|
|
public long now() {
|
|
return System.currentTimeMillis();
|
|
}
|
|
|
|
@Experimental
|
|
public <S extends Scheduler & Subscription> S when(Func1<Observable<Observable<Completable>>, Completable> func1) {
|
|
return new SchedulerWhen(func1, this);
|
|
}
|
|
}
|