MCPcopy Create free account
hub / github.com/grpc/grpc-java / State

Class State

core/src/main/java/io/grpc/internal/AtomicBackoff.java:47–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 }
46
47 @ThreadSafe
48 public final class State {
49 private final long savedValue;
50
51 private State(long value) {
52 this.savedValue = value;
53 }
54
55 public long get() {
56 return savedValue;
57 }
58
59 /**
60 * Causes future invocations of {@link AtomicBackoff#getState} to have a value at least double
61 * this state's value. Subsequent calls to this method will not increase the value further.
62 */
63 public void backoff() {
64 // Use max to handle overflow
65 long newValue = Math.max(savedValue * 2, savedValue);
66 boolean swapped = value.compareAndSet(savedValue, newValue);
67 // Even if swapped is false, the current value should be at least as large as newValue
68 assert value.get() >= newValue;
69 if (swapped) {
70 log.log(Level.WARNING, "Increased {0} to {1}", new Object[] {name, newValue});
71 }
72 }
73 }
74}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected