what-the-bank/sources/com/google/firebase/firestore/util/ExponentialBackoff.java

128 lines
4.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.firestore.util;
import com.google.firebase.firestore.util.AsyncQueue;
import java.util.Date;
/* loaded from: classes2.dex */
public class ExponentialBackoff {
private final double backoffFactor;
private long currentBaseMs;
private final long initialDelayMs;
private long lastAttemptTime = new Date().getTime();
private final long maxDelayMs;
private long nextMaxDelayMs;
private final AsyncQueue queue;
private final AsyncQueue.TimerId timerId;
private AsyncQueue.DelayedTask timerTask;
public ExponentialBackoff(AsyncQueue asyncQueue, AsyncQueue.TimerId timerId, long j, double d, long j2) {
this.queue = asyncQueue;
this.timerId = timerId;
this.initialDelayMs = j;
this.backoffFactor = d;
this.maxDelayMs = j2;
this.nextMaxDelayMs = j2;
reset();
}
/* JADX WARN: Code restructure failed: missing block: B:11:0x0070, code lost:
if (r0 > r2) goto L7;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void backoffAndRun(final java.lang.Runnable r11) {
/*
r10 = this;
r10.cancel()
long r0 = r10.currentBaseMs
long r2 = r10.jitterDelayMs()
long r0 = r0 + r2
java.util.Date r2 = new java.util.Date
r2.<init>()
long r2 = r2.getTime()
long r4 = r10.lastAttemptTime
long r2 = r2 - r4
r4 = 0
long r2 = java.lang.Math.max(r4, r2)
long r6 = r0 - r2
long r6 = java.lang.Math.max(r4, r6)
long r8 = r10.currentBaseMs
int r4 = (r8 > r4 ? 1 : (r8 == r4 ? 0 : -1))
if (r4 <= 0) goto L4b
java.lang.Class r4 = r10.getClass()
java.lang.String r4 = r4.getSimpleName()
long r8 = r10.currentBaseMs
java.lang.Long r5 = java.lang.Long.valueOf(r6)
java.lang.Long r8 = java.lang.Long.valueOf(r8)
java.lang.Long r0 = java.lang.Long.valueOf(r0)
java.lang.Long r1 = java.lang.Long.valueOf(r2)
java.lang.Object[] r0 = new java.lang.Object[]{r5, r8, r0, r1}
java.lang.String r1 = "Backing off for %d ms (base delay: %d ms, delay with jitter: %d ms, last attempt: %d ms ago)"
com.google.firebase.firestore.util.Logger.debug(r4, r1, r0)
L4b:
com.google.firebase.firestore.util.AsyncQueue r0 = r10.queue
com.google.firebase.firestore.util.AsyncQueue$TimerId r1 = r10.timerId
com.google.firebase.firestore.util.ExponentialBackoff$$ExternalSyntheticLambda0 r2 = new com.google.firebase.firestore.util.ExponentialBackoff$$ExternalSyntheticLambda0
r2.<init>(r10, r11)
com.google.firebase.firestore.util.AsyncQueue$DelayedTask r11 = r0.enqueueAfterDelay(r1, r6, r2)
r10.timerTask = r11
long r0 = r10.currentBaseMs
double r0 = (double) r0
double r2 = r10.backoffFactor
double r0 = r0 * r2
long r0 = (long) r0
r10.currentBaseMs = r0
long r2 = r10.initialDelayMs
int r11 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
if (r11 >= 0) goto L6c
L69:
r10.currentBaseMs = r2
goto L73
L6c:
long r2 = r10.nextMaxDelayMs
int r11 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
if (r11 <= 0) goto L73
goto L69
L73:
long r0 = r10.maxDelayMs
r10.nextMaxDelayMs = r0
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.firestore.util.ExponentialBackoff.backoffAndRun(java.lang.Runnable):void");
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: lambda$backoffAndRun$0$com-google-firebase-firestore-util-ExponentialBackoff, reason: not valid java name */
public /* synthetic */ void m257x589b7455(Runnable runnable) {
this.lastAttemptTime = new Date().getTime();
runnable.run();
}
public void cancel() {
AsyncQueue.DelayedTask delayedTask = this.timerTask;
if (delayedTask != null) {
delayedTask.cancel();
this.timerTask = null;
}
}
private long jitterDelayMs() {
return (long) ((Math.random() - 0.5d) * this.currentBaseMs);
}
public void setTemporaryMaxDelay(long j) {
this.nextMaxDelayMs = j;
}
public void resetToMax() {
this.currentBaseMs = this.nextMaxDelayMs;
}
public void reset() {
this.currentBaseMs = 0L;
}
}