in core/src/main/java/com/spotify/metrics/core/LockFreeExponentiallyDecayingReservoir.java [195:205]
private State doRescale(long currentTick, State stateSnapshot) {
State newState = stateSnapshot.rescale(currentTick);
if (stateUpdater.compareAndSet(this, stateSnapshot, newState)) {
// newState successfully installed
return newState;
}
// Otherwise another thread has won the race and we can return the result of a volatile read.
// It's possible this has taken so long that another update is required, however that's unlikely
// and no worse than the standard race between a rescale and update.
return this.state;
}