what-the-bank/sources/io/grpc/internal/AtomicBackoff.java

50 lines
1.5 KiB
Java

package io.grpc.internal;
import com.google.common.base.Preconditions;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
/* loaded from: classes6.dex */
public final class AtomicBackoff {
private static final Logger log = Logger.getLogger(AtomicBackoff.class.getName());
private final String name;
private final AtomicLong value;
public AtomicBackoff(String str, long j) {
AtomicLong atomicLong = new AtomicLong();
this.value = atomicLong;
Preconditions.checkArgument(j > 0, "value must be positive");
this.name = str;
atomicLong.set(j);
}
public final State getState() {
return new State(this.value.get());
}
/* loaded from: classes6.dex */
public final class State {
static final boolean $assertionsDisabled = false;
private final long savedValue;
final AtomicBackoff this$0;
private State(AtomicBackoff atomicBackoff, long j) {
this.this$0 = atomicBackoff;
this.savedValue = j;
}
public final void backoff() {
long j = this.savedValue;
long max = Math.max(2 * j, j);
if (this.this$0.value.compareAndSet(this.savedValue, max)) {
AtomicBackoff.log.log(Level.WARNING, "Increased {0} to {1}", new Object[]{this.this$0.name, Long.valueOf(max)});
}
}
public final long get() {
return this.savedValue;
}
}
}