4368 lines
180 KiB
Java
4368 lines
180 KiB
Java
package com.google.common.cache;
|
|
|
|
import com.google.common.base.Equivalence;
|
|
import com.google.common.base.Function;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.base.Stopwatch;
|
|
import com.google.common.base.Ticker;
|
|
import com.google.common.cache.AbstractCache;
|
|
import com.google.common.cache.CacheBuilder;
|
|
import com.google.common.cache.CacheLoader;
|
|
import com.google.common.collect.AbstractSequentialIterator;
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableSet;
|
|
import com.google.common.collect.Iterators;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Sets;
|
|
import com.google.common.primitives.Ints;
|
|
import com.google.common.util.concurrent.ExecutionError;
|
|
import com.google.common.util.concurrent.Futures;
|
|
import com.google.common.util.concurrent.ListenableFuture;
|
|
import com.google.common.util.concurrent.MoreExecutors;
|
|
import com.google.common.util.concurrent.SettableFuture;
|
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
|
import com.google.common.util.concurrent.Uninterruptibles;
|
|
import com.huawei.hms.framework.common.ContainerUtils;
|
|
import java.io.IOException;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.Serializable;
|
|
import java.lang.ref.Reference;
|
|
import java.lang.ref.ReferenceQueue;
|
|
import java.lang.ref.SoftReference;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.AbstractCollection;
|
|
import java.util.AbstractMap;
|
|
import java.util.AbstractQueue;
|
|
import java.util.AbstractSet;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Map;
|
|
import java.util.NoSuchElementException;
|
|
import java.util.Queue;
|
|
import java.util.Set;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
import java.util.concurrent.ConcurrentMap;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V> {
|
|
static final int CONTAINS_VALUE_RETRIES = 3;
|
|
static final int DRAIN_MAX = 16;
|
|
static final int DRAIN_THRESHOLD = 63;
|
|
static final int MAXIMUM_CAPACITY = 1073741824;
|
|
static final int MAX_SEGMENTS = 65536;
|
|
final int concurrencyLevel;
|
|
final CacheLoader<? super K, V> defaultLoader;
|
|
final EntryFactory entryFactory;
|
|
Set<Map.Entry<K, V>> entrySet;
|
|
final long expireAfterAccessNanos;
|
|
final long expireAfterWriteNanos;
|
|
final AbstractCache.StatsCounter globalStatsCounter;
|
|
final Equivalence<Object> keyEquivalence;
|
|
Set<K> keySet;
|
|
final Strength keyStrength;
|
|
final long maxWeight;
|
|
final long refreshNanos;
|
|
final RemovalListener<K, V> removalListener;
|
|
final Queue<RemovalNotification<K, V>> removalNotificationQueue;
|
|
final int segmentMask;
|
|
final int segmentShift;
|
|
final Segment<K, V>[] segments;
|
|
final Ticker ticker;
|
|
final Equivalence<Object> valueEquivalence;
|
|
final Strength valueStrength;
|
|
Collection<V> values;
|
|
final Weigher<K, V> weigher;
|
|
static final Logger logger = Logger.getLogger(LocalCache.class.getName());
|
|
static final ValueReference<Object, Object> UNSET = new ValueReference<Object, Object>() { // from class: com.google.common.cache.LocalCache.1
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ValueReference<Object, Object> copyFor(ReferenceQueue<Object> referenceQueue, Object obj, ReferenceEntry<Object, Object> referenceEntry) {
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public Object get() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ReferenceEntry<Object, Object> getEntry() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public int getWeight() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isActive() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isLoading() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public void notifyNewValue(Object obj) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public Object waitForValue() {
|
|
return null;
|
|
}
|
|
};
|
|
static final Queue<?> DISCARDING_QUEUE = new AbstractQueue<Object>() { // from class: com.google.common.cache.LocalCache.2
|
|
@Override // java.util.Queue
|
|
public boolean offer(Object obj) {
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public Object peek() {
|
|
return null;
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public Object poll() {
|
|
return null;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public int size() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
|
public Iterator<Object> iterator() {
|
|
return ImmutableSet.of().iterator();
|
|
}
|
|
};
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public enum NullEntry implements ReferenceEntry<Object, Object> {
|
|
INSTANCE;
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final long getAccessTime() {
|
|
return 0L;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final int getHash() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final Object getKey() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<Object, Object> getNext() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<Object, Object> getNextInAccessQueue() {
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<Object, Object> getNextInWriteQueue() {
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<Object, Object> getPreviousInAccessQueue() {
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<Object, Object> getPreviousInWriteQueue() {
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final ValueReference<Object, Object> getValueReference() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final long getWriteTime() {
|
|
return 0L;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final void setAccessTime(long j) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final void setNextInAccessQueue(ReferenceEntry<Object, Object> referenceEntry) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final void setNextInWriteQueue(ReferenceEntry<Object, Object> referenceEntry) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInAccessQueue(ReferenceEntry<Object, Object> referenceEntry) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInWriteQueue(ReferenceEntry<Object, Object> referenceEntry) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final void setValueReference(ValueReference<Object, Object> valueReference) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public final void setWriteTime(long j) {
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public enum Strength {
|
|
STRONG { // from class: com.google.common.cache.LocalCache.Strength.1
|
|
@Override // com.google.common.cache.LocalCache.Strength
|
|
final <K, V> ValueReference<K, V> referenceValue(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, V v, int i) {
|
|
if (i == 1) {
|
|
return new StrongValueReference(v);
|
|
}
|
|
return new WeightedStrongValueReference(v, i);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.Strength
|
|
final Equivalence<Object> defaultEquivalence() {
|
|
return Equivalence.equals();
|
|
}
|
|
},
|
|
SOFT { // from class: com.google.common.cache.LocalCache.Strength.2
|
|
@Override // com.google.common.cache.LocalCache.Strength
|
|
final <K, V> ValueReference<K, V> referenceValue(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, V v, int i) {
|
|
if (i == 1) {
|
|
return new SoftValueReference(segment.valueReferenceQueue, v, referenceEntry);
|
|
}
|
|
return new WeightedSoftValueReference(segment.valueReferenceQueue, v, referenceEntry, i);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.Strength
|
|
final Equivalence<Object> defaultEquivalence() {
|
|
return Equivalence.identity();
|
|
}
|
|
},
|
|
WEAK { // from class: com.google.common.cache.LocalCache.Strength.3
|
|
@Override // com.google.common.cache.LocalCache.Strength
|
|
final <K, V> ValueReference<K, V> referenceValue(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, V v, int i) {
|
|
if (i == 1) {
|
|
return new WeakValueReference(segment.valueReferenceQueue, v, referenceEntry);
|
|
}
|
|
return new WeightedWeakValueReference(segment.valueReferenceQueue, v, referenceEntry, i);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.Strength
|
|
final Equivalence<Object> defaultEquivalence() {
|
|
return Equivalence.identity();
|
|
}
|
|
};
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public abstract Equivalence<Object> defaultEquivalence();
|
|
|
|
abstract <K, V> ValueReference<K, V> referenceValue(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, V v, int i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public interface ValueReference<K, V> {
|
|
ValueReference<K, V> copyFor(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry);
|
|
|
|
V get();
|
|
|
|
ReferenceEntry<K, V> getEntry();
|
|
|
|
int getWeight();
|
|
|
|
boolean isActive();
|
|
|
|
boolean isLoading();
|
|
|
|
void notifyNewValue(V v);
|
|
|
|
V waitForValue() throws ExecutionException;
|
|
}
|
|
|
|
static int rehash(int i) {
|
|
int i2 = i + ((i << 15) ^ (-12931));
|
|
int i3 = i2 ^ (i2 >>> 10);
|
|
int i4 = i3 + (i3 << 3);
|
|
int i5 = i4 ^ (i4 >>> 6);
|
|
int i6 = i5 + (i5 << 2) + (i5 << 14);
|
|
return i6 ^ (i6 >>> 16);
|
|
}
|
|
|
|
LocalCache(CacheBuilder<? super K, ? super V> cacheBuilder, CacheLoader<? super K, V> cacheLoader) {
|
|
Queue<RemovalNotification<K, V>> concurrentLinkedQueue;
|
|
this.concurrencyLevel = Math.min(cacheBuilder.getConcurrencyLevel(), 65536);
|
|
Strength keyStrength = cacheBuilder.getKeyStrength();
|
|
this.keyStrength = keyStrength;
|
|
this.valueStrength = cacheBuilder.getValueStrength();
|
|
this.keyEquivalence = cacheBuilder.getKeyEquivalence();
|
|
this.valueEquivalence = cacheBuilder.getValueEquivalence();
|
|
long maximumWeight = cacheBuilder.getMaximumWeight();
|
|
this.maxWeight = maximumWeight;
|
|
this.weigher = (Weigher<K, V>) cacheBuilder.getWeigher();
|
|
this.expireAfterAccessNanos = cacheBuilder.getExpireAfterAccessNanos();
|
|
this.expireAfterWriteNanos = cacheBuilder.getExpireAfterWriteNanos();
|
|
this.refreshNanos = cacheBuilder.getRefreshNanos();
|
|
CacheBuilder.NullListener nullListener = (RemovalListener<K, V>) cacheBuilder.getRemovalListener();
|
|
this.removalListener = nullListener;
|
|
if (nullListener == CacheBuilder.NullListener.INSTANCE) {
|
|
concurrentLinkedQueue = discardingQueue();
|
|
} else {
|
|
concurrentLinkedQueue = new ConcurrentLinkedQueue<>();
|
|
}
|
|
this.removalNotificationQueue = concurrentLinkedQueue;
|
|
this.ticker = cacheBuilder.getTicker(recordsTime());
|
|
this.entryFactory = EntryFactory.getFactory(keyStrength, usesAccessEntries(), usesWriteEntries());
|
|
this.globalStatsCounter = cacheBuilder.getStatsCounterSupplier().get();
|
|
this.defaultLoader = cacheLoader;
|
|
int min = Math.min(cacheBuilder.getInitialCapacity(), 1073741824);
|
|
if (evictsBySize() && !customWeigher()) {
|
|
min = (int) Math.min(min, maximumWeight);
|
|
}
|
|
int i = 0;
|
|
int i2 = 1;
|
|
int i3 = 0;
|
|
int i4 = 1;
|
|
while (i4 < this.concurrencyLevel && (!evictsBySize() || i4 * 20 <= this.maxWeight)) {
|
|
i3++;
|
|
i4 <<= 1;
|
|
}
|
|
this.segmentShift = 32 - i3;
|
|
this.segmentMask = i4 - 1;
|
|
this.segments = newSegmentArray(i4);
|
|
int i5 = min / i4;
|
|
while (i2 < (i5 * i4 < min ? i5 + 1 : i5)) {
|
|
i2 <<= 1;
|
|
}
|
|
if (evictsBySize()) {
|
|
long j = this.maxWeight;
|
|
long j2 = i4;
|
|
long j3 = (j / j2) + 1;
|
|
while (true) {
|
|
Segment<K, V>[] segmentArr = this.segments;
|
|
if (i >= segmentArr.length) {
|
|
return;
|
|
}
|
|
if (i == j % j2) {
|
|
j3--;
|
|
}
|
|
segmentArr[i] = createSegment(i2, j3, cacheBuilder.getStatsCounterSupplier().get());
|
|
i++;
|
|
}
|
|
} else {
|
|
while (true) {
|
|
Segment<K, V>[] segmentArr2 = this.segments;
|
|
if (i >= segmentArr2.length) {
|
|
return;
|
|
}
|
|
segmentArr2[i] = createSegment(i2, -1L, cacheBuilder.getStatsCounterSupplier().get());
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean customWeigher() {
|
|
return this.weigher != CacheBuilder.OneWeigher.INSTANCE;
|
|
}
|
|
|
|
boolean expires() {
|
|
return expiresAfterWrite() || expiresAfterAccess();
|
|
}
|
|
|
|
boolean usesAccessQueue() {
|
|
return expiresAfterAccess() || evictsBySize();
|
|
}
|
|
|
|
boolean usesWriteQueue() {
|
|
return expiresAfterWrite();
|
|
}
|
|
|
|
boolean recordsWrite() {
|
|
return expiresAfterWrite() || refreshes();
|
|
}
|
|
|
|
boolean recordsAccess() {
|
|
return expiresAfterAccess();
|
|
}
|
|
|
|
boolean recordsTime() {
|
|
return recordsWrite() || recordsAccess();
|
|
}
|
|
|
|
boolean usesWriteEntries() {
|
|
return usesWriteQueue() || recordsWrite();
|
|
}
|
|
|
|
boolean usesAccessEntries() {
|
|
return usesAccessQueue() || recordsAccess();
|
|
}
|
|
|
|
boolean usesKeyReferences() {
|
|
return this.keyStrength != Strength.STRONG;
|
|
}
|
|
|
|
boolean usesValueReferences() {
|
|
return this.valueStrength != Strength.STRONG;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
|
|
/* JADX WARN: Found several "values" enum fields: [] */
|
|
/* loaded from: classes2.dex */
|
|
public static abstract class EntryFactory {
|
|
private static final EntryFactory[] $VALUES;
|
|
static final int ACCESS_MASK = 1;
|
|
public static final EntryFactory STRONG;
|
|
public static final EntryFactory STRONG_ACCESS;
|
|
public static final EntryFactory STRONG_ACCESS_WRITE;
|
|
public static final EntryFactory STRONG_WRITE;
|
|
public static final EntryFactory WEAK;
|
|
public static final EntryFactory WEAK_ACCESS;
|
|
public static final EntryFactory WEAK_ACCESS_WRITE;
|
|
static final int WEAK_MASK = 4;
|
|
public static final EntryFactory WEAK_WRITE;
|
|
static final int WRITE_MASK = 2;
|
|
static final EntryFactory[] factories;
|
|
|
|
abstract <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry);
|
|
|
|
private EntryFactory(String str, int i) {
|
|
}
|
|
|
|
public static EntryFactory valueOf(String str) {
|
|
return (EntryFactory) Enum.valueOf(EntryFactory.class, str);
|
|
}
|
|
|
|
public static EntryFactory[] values() {
|
|
return (EntryFactory[]) $VALUES.clone();
|
|
}
|
|
|
|
static {
|
|
EntryFactory entryFactory = new EntryFactory("STRONG", 0) { // from class: com.google.common.cache.LocalCache.EntryFactory.1
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new StrongEntry(k, i, referenceEntry);
|
|
}
|
|
};
|
|
STRONG = entryFactory;
|
|
EntryFactory entryFactory2 = new EntryFactory("STRONG_ACCESS", 1) { // from class: com.google.common.cache.LocalCache.EntryFactory.2
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new StrongAccessEntry(k, i, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> copyEntry(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
ReferenceEntry<K, V> copyEntry = super.copyEntry(segment, referenceEntry, referenceEntry2);
|
|
copyAccessEntry(referenceEntry, copyEntry);
|
|
return copyEntry;
|
|
}
|
|
};
|
|
STRONG_ACCESS = entryFactory2;
|
|
EntryFactory entryFactory3 = new EntryFactory("STRONG_WRITE", 2) { // from class: com.google.common.cache.LocalCache.EntryFactory.3
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new StrongWriteEntry(k, i, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> copyEntry(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
ReferenceEntry<K, V> copyEntry = super.copyEntry(segment, referenceEntry, referenceEntry2);
|
|
copyWriteEntry(referenceEntry, copyEntry);
|
|
return copyEntry;
|
|
}
|
|
};
|
|
STRONG_WRITE = entryFactory3;
|
|
EntryFactory entryFactory4 = new EntryFactory("STRONG_ACCESS_WRITE", 3) { // from class: com.google.common.cache.LocalCache.EntryFactory.4
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new StrongAccessWriteEntry(k, i, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> copyEntry(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
ReferenceEntry<K, V> copyEntry = super.copyEntry(segment, referenceEntry, referenceEntry2);
|
|
copyAccessEntry(referenceEntry, copyEntry);
|
|
copyWriteEntry(referenceEntry, copyEntry);
|
|
return copyEntry;
|
|
}
|
|
};
|
|
STRONG_ACCESS_WRITE = entryFactory4;
|
|
EntryFactory entryFactory5 = new EntryFactory("WEAK", 4) { // from class: com.google.common.cache.LocalCache.EntryFactory.5
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new WeakEntry(segment.keyReferenceQueue, k, i, referenceEntry);
|
|
}
|
|
};
|
|
WEAK = entryFactory5;
|
|
EntryFactory entryFactory6 = new EntryFactory("WEAK_ACCESS", 5) { // from class: com.google.common.cache.LocalCache.EntryFactory.6
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new WeakAccessEntry(segment.keyReferenceQueue, k, i, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> copyEntry(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
ReferenceEntry<K, V> copyEntry = super.copyEntry(segment, referenceEntry, referenceEntry2);
|
|
copyAccessEntry(referenceEntry, copyEntry);
|
|
return copyEntry;
|
|
}
|
|
};
|
|
WEAK_ACCESS = entryFactory6;
|
|
EntryFactory entryFactory7 = new EntryFactory("WEAK_WRITE", 6) { // from class: com.google.common.cache.LocalCache.EntryFactory.7
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new WeakWriteEntry(segment.keyReferenceQueue, k, i, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> copyEntry(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
ReferenceEntry<K, V> copyEntry = super.copyEntry(segment, referenceEntry, referenceEntry2);
|
|
copyWriteEntry(referenceEntry, copyEntry);
|
|
return copyEntry;
|
|
}
|
|
};
|
|
WEAK_WRITE = entryFactory7;
|
|
EntryFactory entryFactory8 = new EntryFactory("WEAK_ACCESS_WRITE", 7) { // from class: com.google.common.cache.LocalCache.EntryFactory.8
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> newEntry(Segment<K, V> segment, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return new WeakAccessWriteEntry(segment.keyReferenceQueue, k, i, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.EntryFactory
|
|
final <K, V> ReferenceEntry<K, V> copyEntry(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
ReferenceEntry<K, V> copyEntry = super.copyEntry(segment, referenceEntry, referenceEntry2);
|
|
copyAccessEntry(referenceEntry, copyEntry);
|
|
copyWriteEntry(referenceEntry, copyEntry);
|
|
return copyEntry;
|
|
}
|
|
};
|
|
WEAK_ACCESS_WRITE = entryFactory8;
|
|
$VALUES = $values();
|
|
factories = new EntryFactory[]{entryFactory, entryFactory2, entryFactory3, entryFactory4, entryFactory5, entryFactory6, entryFactory7, entryFactory8};
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
static EntryFactory getFactory(Strength strength, boolean z, boolean z2) {
|
|
return factories[(strength == Strength.WEAK ? (char) 4 : (char) 0) | (z ? 1 : 0) | (z2 ? 2 : 0)];
|
|
}
|
|
|
|
<K, V> ReferenceEntry<K, V> copyEntry(Segment<K, V> segment, ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
return newEntry(segment, referenceEntry.getKey(), referenceEntry.getHash(), referenceEntry2);
|
|
}
|
|
|
|
<K, V> void copyAccessEntry(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
referenceEntry2.setAccessTime(referenceEntry.getAccessTime());
|
|
LocalCache.connectAccessOrder(referenceEntry.getPreviousInAccessQueue(), referenceEntry2);
|
|
LocalCache.connectAccessOrder(referenceEntry2, referenceEntry.getNextInAccessQueue());
|
|
LocalCache.nullifyAccessOrder(referenceEntry);
|
|
}
|
|
|
|
<K, V> void copyWriteEntry(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
referenceEntry2.setWriteTime(referenceEntry.getWriteTime());
|
|
LocalCache.connectWriteOrder(referenceEntry.getPreviousInWriteQueue(), referenceEntry2);
|
|
LocalCache.connectWriteOrder(referenceEntry2, referenceEntry.getNextInWriteQueue());
|
|
LocalCache.nullifyWriteOrder(referenceEntry);
|
|
}
|
|
|
|
private static /* synthetic */ EntryFactory[] $values() {
|
|
return new EntryFactory[]{STRONG, STRONG_ACCESS, STRONG_WRITE, STRONG_ACCESS_WRITE, WEAK, WEAK_ACCESS, WEAK_WRITE, WEAK_ACCESS_WRITE};
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static abstract class AbstractReferenceEntry<K, V> implements ReferenceEntry<K, V> {
|
|
AbstractReferenceEntry() {
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ValueReference<K, V> getValueReference() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setValueReference(ValueReference<K, V> valueReference) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getNext() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public int getHash() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public K getKey() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public long getAccessTime() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setAccessTime(long j) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getNextInAccessQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setNextInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getPreviousInAccessQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setPreviousInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public long getWriteTime() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setWriteTime(long j) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getNextInWriteQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setNextInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getPreviousInWriteQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setPreviousInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
static <K, V> ReferenceEntry<K, V> nullEntry() {
|
|
return NullEntry.INSTANCE;
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static class StrongEntry<K, V> extends AbstractReferenceEntry<K, V> {
|
|
final int hash;
|
|
final K key;
|
|
final ReferenceEntry<K, V> next;
|
|
volatile ValueReference<K, V> valueReference = LocalCache.unset();
|
|
|
|
StrongEntry(K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
this.key = k;
|
|
this.hash = i;
|
|
this.next = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public void setValueReference(ValueReference<K, V> valueReference) {
|
|
this.valueReference = valueReference;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public ValueReference<K, V> getValueReference() {
|
|
return this.valueReference;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getNext() {
|
|
return this.next;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public K getKey() {
|
|
return this.key;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public int getHash() {
|
|
return this.hash;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class StrongAccessEntry<K, V> extends StrongEntry<K, V> {
|
|
volatile long accessTime;
|
|
ReferenceEntry<K, V> nextAccess;
|
|
ReferenceEntry<K, V> previousAccess;
|
|
|
|
StrongAccessEntry(K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
super(k, i, referenceEntry);
|
|
this.accessTime = Long.MAX_VALUE;
|
|
this.nextAccess = LocalCache.nullEntry();
|
|
this.previousAccess = LocalCache.nullEntry();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setAccessTime(long j) {
|
|
this.accessTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInAccessQueue() {
|
|
return this.previousAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInAccessQueue() {
|
|
return this.nextAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getAccessTime() {
|
|
return this.accessTime;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class StrongWriteEntry<K, V> extends StrongEntry<K, V> {
|
|
ReferenceEntry<K, V> nextWrite;
|
|
ReferenceEntry<K, V> previousWrite;
|
|
volatile long writeTime;
|
|
|
|
StrongWriteEntry(K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
super(k, i, referenceEntry);
|
|
this.writeTime = Long.MAX_VALUE;
|
|
this.nextWrite = LocalCache.nullEntry();
|
|
this.previousWrite = LocalCache.nullEntry();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setWriteTime(long j) {
|
|
this.writeTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getWriteTime() {
|
|
return this.writeTime;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInWriteQueue() {
|
|
return this.previousWrite;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInWriteQueue() {
|
|
return this.nextWrite;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class StrongAccessWriteEntry<K, V> extends StrongEntry<K, V> {
|
|
volatile long accessTime;
|
|
ReferenceEntry<K, V> nextAccess;
|
|
ReferenceEntry<K, V> nextWrite;
|
|
ReferenceEntry<K, V> previousAccess;
|
|
ReferenceEntry<K, V> previousWrite;
|
|
volatile long writeTime;
|
|
|
|
StrongAccessWriteEntry(K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
super(k, i, referenceEntry);
|
|
this.accessTime = Long.MAX_VALUE;
|
|
this.nextAccess = LocalCache.nullEntry();
|
|
this.previousAccess = LocalCache.nullEntry();
|
|
this.writeTime = Long.MAX_VALUE;
|
|
this.nextWrite = LocalCache.nullEntry();
|
|
this.previousWrite = LocalCache.nullEntry();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setWriteTime(long j) {
|
|
this.writeTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setAccessTime(long j) {
|
|
this.accessTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getWriteTime() {
|
|
return this.writeTime;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInWriteQueue() {
|
|
return this.previousWrite;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInAccessQueue() {
|
|
return this.previousAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInWriteQueue() {
|
|
return this.nextWrite;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInAccessQueue() {
|
|
return this.nextAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getAccessTime() {
|
|
return this.accessTime;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static class WeakEntry<K, V> extends WeakReference<K> implements ReferenceEntry<K, V> {
|
|
final int hash;
|
|
final ReferenceEntry<K, V> next;
|
|
volatile ValueReference<K, V> valueReference;
|
|
|
|
WeakEntry(ReferenceQueue<K> referenceQueue, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
super(k, referenceQueue);
|
|
this.valueReference = LocalCache.unset();
|
|
this.hash = i;
|
|
this.next = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public K getKey() {
|
|
return get();
|
|
}
|
|
|
|
public long getAccessTime() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public void setAccessTime(long j) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public ReferenceEntry<K, V> getNextInAccessQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public void setNextInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public ReferenceEntry<K, V> getPreviousInAccessQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public void setPreviousInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public long getWriteTime() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public void setWriteTime(long j) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public ReferenceEntry<K, V> getNextInWriteQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public void setNextInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public ReferenceEntry<K, V> getPreviousInWriteQueue() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public void setPreviousInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public void setValueReference(ValueReference<K, V> valueReference) {
|
|
this.valueReference = valueReference;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ValueReference<K, V> getValueReference() {
|
|
return this.valueReference;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getNext() {
|
|
return this.next;
|
|
}
|
|
|
|
@Override // com.google.common.cache.ReferenceEntry
|
|
public int getHash() {
|
|
return this.hash;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class WeakAccessEntry<K, V> extends WeakEntry<K, V> {
|
|
volatile long accessTime;
|
|
ReferenceEntry<K, V> nextAccess;
|
|
ReferenceEntry<K, V> previousAccess;
|
|
|
|
WeakAccessEntry(ReferenceQueue<K> referenceQueue, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
super(referenceQueue, k, i, referenceEntry);
|
|
this.accessTime = Long.MAX_VALUE;
|
|
this.nextAccess = LocalCache.nullEntry();
|
|
this.previousAccess = LocalCache.nullEntry();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setAccessTime(long j) {
|
|
this.accessTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInAccessQueue() {
|
|
return this.previousAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInAccessQueue() {
|
|
return this.nextAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getAccessTime() {
|
|
return this.accessTime;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class WeakWriteEntry<K, V> extends WeakEntry<K, V> {
|
|
ReferenceEntry<K, V> nextWrite;
|
|
ReferenceEntry<K, V> previousWrite;
|
|
volatile long writeTime;
|
|
|
|
WeakWriteEntry(ReferenceQueue<K> referenceQueue, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
super(referenceQueue, k, i, referenceEntry);
|
|
this.writeTime = Long.MAX_VALUE;
|
|
this.nextWrite = LocalCache.nullEntry();
|
|
this.previousWrite = LocalCache.nullEntry();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setWriteTime(long j) {
|
|
this.writeTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getWriteTime() {
|
|
return this.writeTime;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInWriteQueue() {
|
|
return this.previousWrite;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInWriteQueue() {
|
|
return this.nextWrite;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class WeakAccessWriteEntry<K, V> extends WeakEntry<K, V> {
|
|
volatile long accessTime;
|
|
ReferenceEntry<K, V> nextAccess;
|
|
ReferenceEntry<K, V> nextWrite;
|
|
ReferenceEntry<K, V> previousAccess;
|
|
ReferenceEntry<K, V> previousWrite;
|
|
volatile long writeTime;
|
|
|
|
WeakAccessWriteEntry(ReferenceQueue<K> referenceQueue, K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
super(referenceQueue, k, i, referenceEntry);
|
|
this.accessTime = Long.MAX_VALUE;
|
|
this.nextAccess = LocalCache.nullEntry();
|
|
this.previousAccess = LocalCache.nullEntry();
|
|
this.writeTime = Long.MAX_VALUE;
|
|
this.nextWrite = LocalCache.nullEntry();
|
|
this.previousWrite = LocalCache.nullEntry();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setWriteTime(long j) {
|
|
this.writeTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setPreviousInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setNextInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final void setAccessTime(long j) {
|
|
this.accessTime = j;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getWriteTime() {
|
|
return this.writeTime;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInWriteQueue() {
|
|
return this.previousWrite;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getPreviousInAccessQueue() {
|
|
return this.previousAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInWriteQueue() {
|
|
return this.nextWrite;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final ReferenceEntry<K, V> getNextInAccessQueue() {
|
|
return this.nextAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakEntry, com.google.common.cache.ReferenceEntry
|
|
public final long getAccessTime() {
|
|
return this.accessTime;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static class WeakValueReference<K, V> extends WeakReference<V> implements ValueReference<K, V> {
|
|
final ReferenceEntry<K, V> entry;
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public int getWeight() {
|
|
return 1;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isActive() {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isLoading() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public void notifyNewValue(V v) {
|
|
}
|
|
|
|
WeakValueReference(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
super(v, referenceQueue);
|
|
this.entry = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ValueReference<K, V> copyFor(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
return new WeakValueReference(referenceQueue, v, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public V waitForValue() {
|
|
return get();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ReferenceEntry<K, V> getEntry() {
|
|
return this.entry;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static class SoftValueReference<K, V> extends SoftReference<V> implements ValueReference<K, V> {
|
|
final ReferenceEntry<K, V> entry;
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public int getWeight() {
|
|
return 1;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isActive() {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isLoading() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public void notifyNewValue(V v) {
|
|
}
|
|
|
|
SoftValueReference(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
super(v, referenceQueue);
|
|
this.entry = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ValueReference<K, V> copyFor(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
return new SoftValueReference(referenceQueue, v, referenceEntry);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public V waitForValue() {
|
|
return get();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ReferenceEntry<K, V> getEntry() {
|
|
return this.entry;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static class StrongValueReference<K, V> implements ValueReference<K, V> {
|
|
final V referent;
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ValueReference<K, V> copyFor(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ReferenceEntry<K, V> getEntry() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public int getWeight() {
|
|
return 1;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isActive() {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isLoading() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public void notifyNewValue(V v) {
|
|
}
|
|
|
|
StrongValueReference(V v) {
|
|
this.referent = v;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public V waitForValue() {
|
|
return get();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public V get() {
|
|
return this.referent;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class WeightedWeakValueReference<K, V> extends WeakValueReference<K, V> {
|
|
final int weight;
|
|
|
|
WeightedWeakValueReference(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry, int i) {
|
|
super(referenceQueue, v, referenceEntry);
|
|
this.weight = i;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakValueReference, com.google.common.cache.LocalCache.ValueReference
|
|
public final ValueReference<K, V> copyFor(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
return new WeightedWeakValueReference(referenceQueue, v, referenceEntry, this.weight);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.WeakValueReference, com.google.common.cache.LocalCache.ValueReference
|
|
public final int getWeight() {
|
|
return this.weight;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class WeightedSoftValueReference<K, V> extends SoftValueReference<K, V> {
|
|
final int weight;
|
|
|
|
WeightedSoftValueReference(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry, int i) {
|
|
super(referenceQueue, v, referenceEntry);
|
|
this.weight = i;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.SoftValueReference, com.google.common.cache.LocalCache.ValueReference
|
|
public final ValueReference<K, V> copyFor(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
return new WeightedSoftValueReference(referenceQueue, v, referenceEntry, this.weight);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.SoftValueReference, com.google.common.cache.LocalCache.ValueReference
|
|
public final int getWeight() {
|
|
return this.weight;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class WeightedStrongValueReference<K, V> extends StrongValueReference<K, V> {
|
|
final int weight;
|
|
|
|
WeightedStrongValueReference(V v, int i) {
|
|
super(v);
|
|
this.weight = i;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.StrongValueReference, com.google.common.cache.LocalCache.ValueReference
|
|
public final int getWeight() {
|
|
return this.weight;
|
|
}
|
|
}
|
|
|
|
ReferenceEntry<K, V> newEntry(K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
Segment<K, V> segmentFor = segmentFor(i);
|
|
segmentFor.lock();
|
|
try {
|
|
return segmentFor.newEntry(k, i, referenceEntry);
|
|
} finally {
|
|
segmentFor.unlock();
|
|
}
|
|
}
|
|
|
|
ReferenceEntry<K, V> copyEntry(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
return segmentFor(referenceEntry.getHash()).copyEntry(referenceEntry, referenceEntry2);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
ValueReference<K, V> newValueReference(ReferenceEntry<K, V> referenceEntry, V v, int i) {
|
|
return this.valueStrength.referenceValue(segmentFor(referenceEntry.getHash()), referenceEntry, Preconditions.checkNotNull(v), i);
|
|
}
|
|
|
|
int hash(Object obj) {
|
|
return rehash(this.keyEquivalence.hash(obj));
|
|
}
|
|
|
|
void reclaimValue(ValueReference<K, V> valueReference) {
|
|
ReferenceEntry<K, V> entry = valueReference.getEntry();
|
|
int hash = entry.getHash();
|
|
segmentFor(hash).reclaimValue(entry.getKey(), hash, valueReference);
|
|
}
|
|
|
|
void reclaimKey(ReferenceEntry<K, V> referenceEntry) {
|
|
int hash = referenceEntry.getHash();
|
|
segmentFor(hash).reclaimKey(referenceEntry, hash);
|
|
}
|
|
|
|
boolean isLive(ReferenceEntry<K, V> referenceEntry, long j) {
|
|
return segmentFor(referenceEntry.getHash()).getLiveValue(referenceEntry, j) != null;
|
|
}
|
|
|
|
Segment<K, V> segmentFor(int i) {
|
|
return this.segments[(i >>> this.segmentShift) & this.segmentMask];
|
|
}
|
|
|
|
Segment<K, V> createSegment(int i, long j, AbstractCache.StatsCounter statsCounter) {
|
|
return new Segment<>(this, i, j, statsCounter);
|
|
}
|
|
|
|
V getLiveValue(ReferenceEntry<K, V> referenceEntry, long j) {
|
|
V v;
|
|
if (referenceEntry.getKey() == null || (v = referenceEntry.getValueReference().get()) == null || isExpired(referenceEntry, j)) {
|
|
return null;
|
|
}
|
|
return v;
|
|
}
|
|
|
|
boolean isExpired(ReferenceEntry<K, V> referenceEntry, long j) {
|
|
Preconditions.checkNotNull(referenceEntry);
|
|
if (!expiresAfterAccess() || j - referenceEntry.getAccessTime() < this.expireAfterAccessNanos) {
|
|
return expiresAfterWrite() && j - referenceEntry.getWriteTime() >= this.expireAfterWriteNanos;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static <K, V> void connectAccessOrder(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
referenceEntry.setNextInAccessQueue(referenceEntry2);
|
|
referenceEntry2.setPreviousInAccessQueue(referenceEntry);
|
|
}
|
|
|
|
static <K, V> void nullifyAccessOrder(ReferenceEntry<K, V> referenceEntry) {
|
|
ReferenceEntry<K, V> nullEntry = nullEntry();
|
|
referenceEntry.setNextInAccessQueue(nullEntry);
|
|
referenceEntry.setPreviousInAccessQueue(nullEntry);
|
|
}
|
|
|
|
static <K, V> void connectWriteOrder(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
referenceEntry.setNextInWriteQueue(referenceEntry2);
|
|
referenceEntry2.setPreviousInWriteQueue(referenceEntry);
|
|
}
|
|
|
|
static <K, V> void nullifyWriteOrder(ReferenceEntry<K, V> referenceEntry) {
|
|
ReferenceEntry<K, V> nullEntry = nullEntry();
|
|
referenceEntry.setNextInWriteQueue(nullEntry);
|
|
referenceEntry.setPreviousInWriteQueue(nullEntry);
|
|
}
|
|
|
|
void processPendingNotifications() {
|
|
while (true) {
|
|
RemovalNotification<K, V> poll = this.removalNotificationQueue.poll();
|
|
if (poll == null) {
|
|
return;
|
|
}
|
|
try {
|
|
this.removalListener.onRemoval(poll);
|
|
} catch (Throwable th) {
|
|
logger.log(Level.WARNING, "Exception thrown by removal listener", th);
|
|
}
|
|
}
|
|
}
|
|
|
|
final Segment<K, V>[] newSegmentArray(int i) {
|
|
return new Segment[i];
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class Segment<K, V> extends ReentrantLock {
|
|
final Queue<ReferenceEntry<K, V>> accessQueue;
|
|
volatile int count;
|
|
final ReferenceQueue<K> keyReferenceQueue;
|
|
final LocalCache<K, V> map;
|
|
final long maxSegmentWeight;
|
|
int modCount;
|
|
final AtomicInteger readCount = new AtomicInteger();
|
|
final Queue<ReferenceEntry<K, V>> recencyQueue;
|
|
final AbstractCache.StatsCounter statsCounter;
|
|
volatile AtomicReferenceArray<ReferenceEntry<K, V>> table;
|
|
int threshold;
|
|
long totalWeight;
|
|
final ReferenceQueue<V> valueReferenceQueue;
|
|
final Queue<ReferenceEntry<K, V>> writeQueue;
|
|
|
|
Segment(LocalCache<K, V> localCache, int i, long j, AbstractCache.StatsCounter statsCounter) {
|
|
Queue<ReferenceEntry<K, V>> discardingQueue;
|
|
Queue<ReferenceEntry<K, V>> discardingQueue2;
|
|
Queue<ReferenceEntry<K, V>> discardingQueue3;
|
|
this.map = localCache;
|
|
this.maxSegmentWeight = j;
|
|
this.statsCounter = (AbstractCache.StatsCounter) Preconditions.checkNotNull(statsCounter);
|
|
initTable(newEntryArray(i));
|
|
this.keyReferenceQueue = localCache.usesKeyReferences() ? new ReferenceQueue<>() : null;
|
|
this.valueReferenceQueue = localCache.usesValueReferences() ? new ReferenceQueue<>() : null;
|
|
if (localCache.usesAccessQueue()) {
|
|
discardingQueue = new ConcurrentLinkedQueue<>();
|
|
} else {
|
|
discardingQueue = LocalCache.discardingQueue();
|
|
}
|
|
this.recencyQueue = discardingQueue;
|
|
if (localCache.usesWriteQueue()) {
|
|
discardingQueue2 = new WriteQueue<>();
|
|
} else {
|
|
discardingQueue2 = LocalCache.discardingQueue();
|
|
}
|
|
this.writeQueue = discardingQueue2;
|
|
if (localCache.usesAccessQueue()) {
|
|
discardingQueue3 = new AccessQueue<>();
|
|
} else {
|
|
discardingQueue3 = LocalCache.discardingQueue();
|
|
}
|
|
this.accessQueue = discardingQueue3;
|
|
}
|
|
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> newEntryArray(int i) {
|
|
return new AtomicReferenceArray<>(i);
|
|
}
|
|
|
|
void initTable(AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray) {
|
|
this.threshold = (atomicReferenceArray.length() * 3) / 4;
|
|
if (!this.map.customWeigher()) {
|
|
int i = this.threshold;
|
|
if (i == this.maxSegmentWeight) {
|
|
this.threshold = i + 1;
|
|
}
|
|
}
|
|
this.table = atomicReferenceArray;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
ReferenceEntry<K, V> newEntry(K k, int i, ReferenceEntry<K, V> referenceEntry) {
|
|
return this.map.entryFactory.newEntry(this, Preconditions.checkNotNull(k), i, referenceEntry);
|
|
}
|
|
|
|
ReferenceEntry<K, V> copyEntry(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
if (referenceEntry.getKey() == null) {
|
|
return null;
|
|
}
|
|
ValueReference<K, V> valueReference = referenceEntry.getValueReference();
|
|
V v = valueReference.get();
|
|
if (v == null && valueReference.isActive()) {
|
|
return null;
|
|
}
|
|
ReferenceEntry<K, V> copyEntry = this.map.entryFactory.copyEntry(this, referenceEntry, referenceEntry2);
|
|
copyEntry.setValueReference(valueReference.copyFor(this.valueReferenceQueue, v, copyEntry));
|
|
return copyEntry;
|
|
}
|
|
|
|
void setValue(ReferenceEntry<K, V> referenceEntry, K k, V v, long j) {
|
|
ValueReference<K, V> valueReference = referenceEntry.getValueReference();
|
|
int weigh = this.map.weigher.weigh(k, v);
|
|
Preconditions.checkState(weigh >= 0, "Weights must be non-negative");
|
|
referenceEntry.setValueReference(this.map.valueStrength.referenceValue(this, referenceEntry, v, weigh));
|
|
recordWrite(referenceEntry, weigh, j);
|
|
valueReference.notifyNewValue(v);
|
|
}
|
|
|
|
V get(K k, int i, CacheLoader<? super K, V> cacheLoader) throws ExecutionException {
|
|
ReferenceEntry<K, V> entry;
|
|
Preconditions.checkNotNull(k);
|
|
Preconditions.checkNotNull(cacheLoader);
|
|
try {
|
|
try {
|
|
if (this.count != 0 && (entry = getEntry(k, i)) != null) {
|
|
long read = this.map.ticker.read();
|
|
V liveValue = getLiveValue(entry, read);
|
|
if (liveValue != null) {
|
|
recordRead(entry, read);
|
|
this.statsCounter.recordHits(1);
|
|
return scheduleRefresh(entry, k, i, liveValue, read, cacheLoader);
|
|
}
|
|
ValueReference<K, V> valueReference = entry.getValueReference();
|
|
if (valueReference.isLoading()) {
|
|
return waitForLoadingValue(entry, k, valueReference);
|
|
}
|
|
}
|
|
return lockedGetOrLoad(k, i, cacheLoader);
|
|
} catch (ExecutionException e) {
|
|
Throwable cause = e.getCause();
|
|
if (cause instanceof Error) {
|
|
throw new ExecutionError((Error) cause);
|
|
}
|
|
if (cause instanceof RuntimeException) {
|
|
throw new UncheckedExecutionException(cause);
|
|
}
|
|
throw e;
|
|
}
|
|
} finally {
|
|
postReadCleanup();
|
|
}
|
|
}
|
|
|
|
V get(Object obj, int i) {
|
|
try {
|
|
if (this.count != 0) {
|
|
long read = this.map.ticker.read();
|
|
ReferenceEntry<K, V> liveEntry = getLiveEntry(obj, i, read);
|
|
if (liveEntry == null) {
|
|
return null;
|
|
}
|
|
V v = liveEntry.getValueReference().get();
|
|
if (v != null) {
|
|
recordRead(liveEntry, read);
|
|
return scheduleRefresh(liveEntry, liveEntry.getKey(), i, v, read, this.map.defaultLoader);
|
|
}
|
|
tryDrainReferenceQueues();
|
|
}
|
|
return null;
|
|
} finally {
|
|
postReadCleanup();
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:16:0x009f, code lost:
|
|
|
|
if (r1 == false) goto L32;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:17:0x00a1, code lost:
|
|
|
|
r15 = new com.google.common.cache.LocalCache.LoadingValueReference<>();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:18:0x00a6, code lost:
|
|
|
|
if (r14 != null) goto L31;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:19:0x00a8, code lost:
|
|
|
|
r14 = newEntry(r18, r19, r13);
|
|
r14.setValueReference(r15);
|
|
r10.set(r12, r14);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:20:0x00b3, code lost:
|
|
|
|
r14.setValueReference(r15);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:22:0x00bc, code lost:
|
|
|
|
if (r1 == false) goto L46;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:24:0x00da, code lost:
|
|
|
|
return waitForLoadingValue(r14, r18, r2);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:27:0x00be, code lost:
|
|
|
|
monitor-enter(r14);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:30:0x00c1, code lost:
|
|
|
|
r0 = loadSync(r18, r19, r15, r20);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:31:0x00c5, code lost:
|
|
|
|
monitor-exit(r14);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:33:0x00cb, code lost:
|
|
|
|
return r0;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:38:0x00cf, code lost:
|
|
|
|
r0 = move-exception;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:39:0x00d0, code lost:
|
|
|
|
r17.statsCounter.recordMisses(1);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:40:0x00d5, code lost:
|
|
|
|
throw r0;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
V lockedGetOrLoad(K r18, int r19, com.google.common.cache.CacheLoader<? super K, V> r20) throws java.util.concurrent.ExecutionException {
|
|
/*
|
|
Method dump skipped, instructions count: 227
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.common.cache.LocalCache.Segment.lockedGetOrLoad(java.lang.Object, int, com.google.common.cache.CacheLoader):java.lang.Object");
|
|
}
|
|
|
|
V waitForLoadingValue(ReferenceEntry<K, V> referenceEntry, K k, ValueReference<K, V> valueReference) throws ExecutionException {
|
|
if (!valueReference.isLoading()) {
|
|
throw new AssertionError();
|
|
}
|
|
Preconditions.checkState(!Thread.holdsLock(referenceEntry), "Recursive load of: %s", k);
|
|
try {
|
|
V waitForValue = valueReference.waitForValue();
|
|
if (waitForValue == null) {
|
|
String valueOf = String.valueOf(k);
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 35);
|
|
sb.append("CacheLoader returned null for key ");
|
|
sb.append(valueOf);
|
|
sb.append(".");
|
|
throw new CacheLoader.InvalidCacheLoadException(sb.toString());
|
|
}
|
|
recordRead(referenceEntry, this.map.ticker.read());
|
|
return waitForValue;
|
|
} finally {
|
|
this.statsCounter.recordMisses(1);
|
|
}
|
|
}
|
|
|
|
V loadSync(K k, int i, LoadingValueReference<K, V> loadingValueReference, CacheLoader<? super K, V> cacheLoader) throws ExecutionException {
|
|
return getAndRecordStats(k, i, loadingValueReference, loadingValueReference.loadFuture(k, cacheLoader));
|
|
}
|
|
|
|
ListenableFuture<V> loadAsync(K k, int i, LoadingValueReference<K, V> loadingValueReference, CacheLoader<? super K, V> cacheLoader) {
|
|
ListenableFuture<V> loadFuture = loadingValueReference.loadFuture(k, cacheLoader);
|
|
loadFuture.addListener(new Runnable(this, k, i, loadingValueReference, loadFuture) { // from class: com.google.common.cache.LocalCache.Segment.1
|
|
final Segment this$0;
|
|
final int val$hash;
|
|
final Object val$key;
|
|
final ListenableFuture val$loadingFuture;
|
|
final LoadingValueReference val$loadingValueReference;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
this.val$key = k;
|
|
this.val$hash = i;
|
|
this.val$loadingValueReference = loadingValueReference;
|
|
this.val$loadingFuture = loadFuture;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
this.this$0.getAndRecordStats(this.val$key, this.val$hash, this.val$loadingValueReference, this.val$loadingFuture);
|
|
} catch (Throwable th) {
|
|
LocalCache.logger.log(Level.WARNING, "Exception thrown during refresh", th);
|
|
this.val$loadingValueReference.setException(th);
|
|
}
|
|
}
|
|
}, MoreExecutors.directExecutor());
|
|
return loadFuture;
|
|
}
|
|
|
|
V getAndRecordStats(K k, int i, LoadingValueReference<K, V> loadingValueReference, ListenableFuture<V> listenableFuture) throws ExecutionException {
|
|
V v;
|
|
try {
|
|
v = (V) Uninterruptibles.getUninterruptibly(listenableFuture);
|
|
try {
|
|
if (v == null) {
|
|
String valueOf = String.valueOf(k);
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 35);
|
|
sb.append("CacheLoader returned null for key ");
|
|
sb.append(valueOf);
|
|
sb.append(".");
|
|
throw new CacheLoader.InvalidCacheLoadException(sb.toString());
|
|
}
|
|
this.statsCounter.recordLoadSuccess(loadingValueReference.elapsedNanos());
|
|
storeLoadedValue(k, i, loadingValueReference, v);
|
|
if (v == null) {
|
|
this.statsCounter.recordLoadException(loadingValueReference.elapsedNanos());
|
|
removeLoadingValue(k, i, loadingValueReference);
|
|
}
|
|
return v;
|
|
} catch (Throwable th) {
|
|
th = th;
|
|
if (v == null) {
|
|
this.statsCounter.recordLoadException(loadingValueReference.elapsedNanos());
|
|
removeLoadingValue(k, i, loadingValueReference);
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
v = null;
|
|
}
|
|
}
|
|
|
|
V scheduleRefresh(ReferenceEntry<K, V> referenceEntry, K k, int i, V v, long j, CacheLoader<? super K, V> cacheLoader) {
|
|
V refresh;
|
|
return (!this.map.refreshes() || j - referenceEntry.getWriteTime() <= this.map.refreshNanos || referenceEntry.getValueReference().isLoading() || (refresh = refresh(k, i, cacheLoader, true)) == null) ? v : refresh;
|
|
}
|
|
|
|
V refresh(K k, int i, CacheLoader<? super K, V> cacheLoader, boolean z) {
|
|
LoadingValueReference<K, V> insertLoadingValueReference = insertLoadingValueReference(k, i, z);
|
|
if (insertLoadingValueReference == null) {
|
|
return null;
|
|
}
|
|
ListenableFuture<V> loadAsync = loadAsync(k, i, insertLoadingValueReference, cacheLoader);
|
|
if (loadAsync.isDone()) {
|
|
try {
|
|
return (V) Uninterruptibles.getUninterruptibly(loadAsync);
|
|
} catch (Throwable unused) {
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
LoadingValueReference<K, V> insertLoadingValueReference(K k, int i, boolean z) {
|
|
lock();
|
|
try {
|
|
long read = this.map.ticker.read();
|
|
preWriteCleanup(read);
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = (atomicReferenceArray.length() - 1) & i;
|
|
ReferenceEntry<K, V> referenceEntry = (ReferenceEntry) atomicReferenceArray.get(length);
|
|
for (ReferenceEntry referenceEntry2 = referenceEntry; referenceEntry2 != null; referenceEntry2 = referenceEntry2.getNext()) {
|
|
Object key = referenceEntry2.getKey();
|
|
if (referenceEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
|
|
ValueReference<K, V> valueReference = referenceEntry2.getValueReference();
|
|
if (!valueReference.isLoading() && (!z || read - referenceEntry2.getWriteTime() >= this.map.refreshNanos)) {
|
|
this.modCount++;
|
|
LoadingValueReference<K, V> loadingValueReference = new LoadingValueReference<>(valueReference);
|
|
referenceEntry2.setValueReference(loadingValueReference);
|
|
return loadingValueReference;
|
|
}
|
|
unlock();
|
|
postWriteCleanup();
|
|
return null;
|
|
}
|
|
}
|
|
this.modCount++;
|
|
LoadingValueReference<K, V> loadingValueReference2 = new LoadingValueReference<>();
|
|
ReferenceEntry<K, V> newEntry = newEntry(k, i, referenceEntry);
|
|
newEntry.setValueReference(loadingValueReference2);
|
|
atomicReferenceArray.set(length, newEntry);
|
|
return loadingValueReference2;
|
|
} finally {
|
|
unlock();
|
|
postWriteCleanup();
|
|
}
|
|
}
|
|
|
|
void tryDrainReferenceQueues() {
|
|
if (tryLock()) {
|
|
try {
|
|
drainReferenceQueues();
|
|
} finally {
|
|
unlock();
|
|
}
|
|
}
|
|
}
|
|
|
|
void drainReferenceQueues() {
|
|
if (this.map.usesKeyReferences()) {
|
|
drainKeyReferenceQueue();
|
|
}
|
|
if (this.map.usesValueReferences()) {
|
|
drainValueReferenceQueue();
|
|
}
|
|
}
|
|
|
|
void drainKeyReferenceQueue() {
|
|
int i = 0;
|
|
do {
|
|
Reference<? extends K> poll = this.keyReferenceQueue.poll();
|
|
if (poll == null) {
|
|
return;
|
|
}
|
|
this.map.reclaimKey((ReferenceEntry) poll);
|
|
i++;
|
|
} while (i != 16);
|
|
}
|
|
|
|
void drainValueReferenceQueue() {
|
|
int i = 0;
|
|
do {
|
|
Reference<? extends V> poll = this.valueReferenceQueue.poll();
|
|
if (poll == null) {
|
|
return;
|
|
}
|
|
this.map.reclaimValue((ValueReference) poll);
|
|
i++;
|
|
} while (i != 16);
|
|
}
|
|
|
|
void clearReferenceQueues() {
|
|
if (this.map.usesKeyReferences()) {
|
|
clearKeyReferenceQueue();
|
|
}
|
|
if (this.map.usesValueReferences()) {
|
|
clearValueReferenceQueue();
|
|
}
|
|
}
|
|
|
|
void clearKeyReferenceQueue() {
|
|
do {
|
|
} while (this.keyReferenceQueue.poll() != null);
|
|
}
|
|
|
|
void clearValueReferenceQueue() {
|
|
do {
|
|
} while (this.valueReferenceQueue.poll() != null);
|
|
}
|
|
|
|
void recordRead(ReferenceEntry<K, V> referenceEntry, long j) {
|
|
if (this.map.recordsAccess()) {
|
|
referenceEntry.setAccessTime(j);
|
|
}
|
|
this.recencyQueue.add(referenceEntry);
|
|
}
|
|
|
|
void recordLockedRead(ReferenceEntry<K, V> referenceEntry, long j) {
|
|
if (this.map.recordsAccess()) {
|
|
referenceEntry.setAccessTime(j);
|
|
}
|
|
this.accessQueue.add(referenceEntry);
|
|
}
|
|
|
|
void recordWrite(ReferenceEntry<K, V> referenceEntry, int i, long j) {
|
|
drainRecencyQueue();
|
|
this.totalWeight += i;
|
|
if (this.map.recordsAccess()) {
|
|
referenceEntry.setAccessTime(j);
|
|
}
|
|
if (this.map.recordsWrite()) {
|
|
referenceEntry.setWriteTime(j);
|
|
}
|
|
this.accessQueue.add(referenceEntry);
|
|
this.writeQueue.add(referenceEntry);
|
|
}
|
|
|
|
void drainRecencyQueue() {
|
|
while (true) {
|
|
ReferenceEntry<K, V> poll = this.recencyQueue.poll();
|
|
if (poll == null) {
|
|
return;
|
|
}
|
|
if (this.accessQueue.contains(poll)) {
|
|
this.accessQueue.add(poll);
|
|
}
|
|
}
|
|
}
|
|
|
|
void tryExpireEntries(long j) {
|
|
if (tryLock()) {
|
|
try {
|
|
expireEntries(j);
|
|
} finally {
|
|
unlock();
|
|
}
|
|
}
|
|
}
|
|
|
|
void expireEntries(long j) {
|
|
ReferenceEntry<K, V> peek;
|
|
ReferenceEntry<K, V> peek2;
|
|
drainRecencyQueue();
|
|
do {
|
|
peek = this.writeQueue.peek();
|
|
if (peek == null || !this.map.isExpired(peek, j)) {
|
|
do {
|
|
peek2 = this.accessQueue.peek();
|
|
if (peek2 == null || !this.map.isExpired(peek2, j)) {
|
|
return;
|
|
}
|
|
} while (removeEntry(peek2, peek2.getHash(), RemovalCause.EXPIRED));
|
|
throw new AssertionError();
|
|
}
|
|
} while (removeEntry(peek, peek.getHash(), RemovalCause.EXPIRED));
|
|
throw new AssertionError();
|
|
}
|
|
|
|
void enqueueNotification(K k, int i, V v, int i2, RemovalCause removalCause) {
|
|
this.totalWeight -= i2;
|
|
if (removalCause.wasEvicted()) {
|
|
this.statsCounter.recordEviction();
|
|
}
|
|
if (this.map.removalNotificationQueue != LocalCache.DISCARDING_QUEUE) {
|
|
this.map.removalNotificationQueue.offer(RemovalNotification.create(k, v, removalCause));
|
|
}
|
|
}
|
|
|
|
void evictEntries(ReferenceEntry<K, V> referenceEntry) {
|
|
if (this.map.evictsBySize()) {
|
|
drainRecencyQueue();
|
|
if (referenceEntry.getValueReference().getWeight() > this.maxSegmentWeight && !removeEntry(referenceEntry, referenceEntry.getHash(), RemovalCause.SIZE)) {
|
|
throw new AssertionError();
|
|
}
|
|
while (this.totalWeight > this.maxSegmentWeight) {
|
|
ReferenceEntry<K, V> nextEvictable = getNextEvictable();
|
|
if (!removeEntry(nextEvictable, nextEvictable.getHash(), RemovalCause.SIZE)) {
|
|
throw new AssertionError();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ReferenceEntry<K, V> getNextEvictable() {
|
|
for (ReferenceEntry<K, V> referenceEntry : this.accessQueue) {
|
|
if (referenceEntry.getValueReference().getWeight() > 0) {
|
|
return referenceEntry;
|
|
}
|
|
}
|
|
throw new AssertionError();
|
|
}
|
|
|
|
ReferenceEntry<K, V> getFirst(int i) {
|
|
return this.table.get(i & (r0.length() - 1));
|
|
}
|
|
|
|
ReferenceEntry<K, V> getEntry(Object obj, int i) {
|
|
for (ReferenceEntry<K, V> first = getFirst(i); first != null; first = first.getNext()) {
|
|
if (first.getHash() == i) {
|
|
K key = first.getKey();
|
|
if (key == null) {
|
|
tryDrainReferenceQueues();
|
|
} else if (this.map.keyEquivalence.equivalent(obj, key)) {
|
|
return first;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
ReferenceEntry<K, V> getLiveEntry(Object obj, int i, long j) {
|
|
ReferenceEntry<K, V> entry = getEntry(obj, i);
|
|
if (entry == null) {
|
|
return null;
|
|
}
|
|
if (!this.map.isExpired(entry, j)) {
|
|
return entry;
|
|
}
|
|
tryExpireEntries(j);
|
|
return null;
|
|
}
|
|
|
|
V getLiveValue(ReferenceEntry<K, V> referenceEntry, long j) {
|
|
if (referenceEntry.getKey() == null) {
|
|
tryDrainReferenceQueues();
|
|
return null;
|
|
}
|
|
V v = referenceEntry.getValueReference().get();
|
|
if (v == null) {
|
|
tryDrainReferenceQueues();
|
|
return null;
|
|
}
|
|
if (!this.map.isExpired(referenceEntry, j)) {
|
|
return v;
|
|
}
|
|
tryExpireEntries(j);
|
|
return null;
|
|
}
|
|
|
|
boolean containsKey(Object obj, int i) {
|
|
try {
|
|
if (this.count == 0) {
|
|
return false;
|
|
}
|
|
ReferenceEntry<K, V> liveEntry = getLiveEntry(obj, i, this.map.ticker.read());
|
|
if (liveEntry == null) {
|
|
return false;
|
|
}
|
|
return liveEntry.getValueReference().get() != null;
|
|
} finally {
|
|
postReadCleanup();
|
|
}
|
|
}
|
|
|
|
boolean containsValue(Object obj) {
|
|
try {
|
|
if (this.count != 0) {
|
|
long read = this.map.ticker.read();
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = atomicReferenceArray.length();
|
|
for (int i = 0; i < length; i++) {
|
|
for (ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(i); referenceEntry != null; referenceEntry = referenceEntry.getNext()) {
|
|
V liveValue = getLiveValue(referenceEntry, read);
|
|
if (liveValue != null && this.map.valueEquivalence.equivalent(obj, liveValue)) {
|
|
postReadCleanup();
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
} finally {
|
|
postReadCleanup();
|
|
}
|
|
}
|
|
|
|
V put(K k, int i, V v, boolean z) {
|
|
int i2;
|
|
lock();
|
|
try {
|
|
long read = this.map.ticker.read();
|
|
preWriteCleanup(read);
|
|
if (this.count + 1 > this.threshold) {
|
|
expand();
|
|
}
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = i & (atomicReferenceArray.length() - 1);
|
|
ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(length);
|
|
ReferenceEntry<K, V> referenceEntry2 = referenceEntry;
|
|
while (true) {
|
|
if (referenceEntry2 == null) {
|
|
this.modCount++;
|
|
ReferenceEntry<K, V> newEntry = newEntry(k, i, referenceEntry);
|
|
setValue(newEntry, k, v, read);
|
|
atomicReferenceArray.set(length, newEntry);
|
|
this.count++;
|
|
evictEntries(newEntry);
|
|
break;
|
|
}
|
|
K key = referenceEntry2.getKey();
|
|
if (referenceEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
|
|
ValueReference<K, V> valueReference = referenceEntry2.getValueReference();
|
|
V v2 = valueReference.get();
|
|
if (v2 != null) {
|
|
if (z) {
|
|
recordLockedRead(referenceEntry2, read);
|
|
} else {
|
|
this.modCount++;
|
|
enqueueNotification(k, i, v2, valueReference.getWeight(), RemovalCause.REPLACED);
|
|
setValue(referenceEntry2, k, v, read);
|
|
evictEntries(referenceEntry2);
|
|
}
|
|
return v2;
|
|
}
|
|
this.modCount++;
|
|
if (valueReference.isActive()) {
|
|
enqueueNotification(k, i, v2, valueReference.getWeight(), RemovalCause.COLLECTED);
|
|
setValue(referenceEntry2, k, v, read);
|
|
i2 = this.count;
|
|
} else {
|
|
setValue(referenceEntry2, k, v, read);
|
|
i2 = this.count + 1;
|
|
}
|
|
this.count = i2;
|
|
evictEntries(referenceEntry2);
|
|
} else {
|
|
referenceEntry2 = referenceEntry2.getNext();
|
|
}
|
|
}
|
|
unlock();
|
|
postWriteCleanup();
|
|
return null;
|
|
} finally {
|
|
unlock();
|
|
postWriteCleanup();
|
|
}
|
|
}
|
|
|
|
void expand() {
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = atomicReferenceArray.length();
|
|
if (length >= 1073741824) {
|
|
return;
|
|
}
|
|
int i = this.count;
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> newEntryArray = newEntryArray(length << 1);
|
|
this.threshold = (newEntryArray.length() * 3) / 4;
|
|
int length2 = newEntryArray.length() - 1;
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(i2);
|
|
if (referenceEntry != null) {
|
|
ReferenceEntry<K, V> next = referenceEntry.getNext();
|
|
int hash = referenceEntry.getHash() & length2;
|
|
if (next == null) {
|
|
newEntryArray.set(hash, referenceEntry);
|
|
} else {
|
|
ReferenceEntry<K, V> referenceEntry2 = referenceEntry;
|
|
while (next != null) {
|
|
int hash2 = next.getHash() & length2;
|
|
if (hash2 != hash) {
|
|
referenceEntry2 = next;
|
|
hash = hash2;
|
|
}
|
|
next = next.getNext();
|
|
}
|
|
newEntryArray.set(hash, referenceEntry2);
|
|
while (referenceEntry != referenceEntry2) {
|
|
int hash3 = referenceEntry.getHash() & length2;
|
|
ReferenceEntry<K, V> copyEntry = copyEntry(referenceEntry, newEntryArray.get(hash3));
|
|
if (copyEntry != null) {
|
|
newEntryArray.set(hash3, copyEntry);
|
|
} else {
|
|
removeCollectedEntry(referenceEntry);
|
|
i--;
|
|
}
|
|
referenceEntry = referenceEntry.getNext();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.table = newEntryArray;
|
|
this.count = i;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:16:0x00ad, code lost:
|
|
|
|
unlock();
|
|
postWriteCleanup();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:17:0x00b4, code lost:
|
|
|
|
return false;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
boolean replace(K r17, int r18, V r19, V r20) {
|
|
/*
|
|
r16 = this;
|
|
r9 = r16
|
|
r0 = r18
|
|
r16.lock()
|
|
com.google.common.cache.LocalCache<K, V> r1 = r9.map // Catch: java.lang.Throwable -> Lb5
|
|
com.google.common.base.Ticker r1 = r1.ticker // Catch: java.lang.Throwable -> Lb5
|
|
long r7 = r1.read() // Catch: java.lang.Throwable -> Lb5
|
|
r9.preWriteCleanup(r7) // Catch: java.lang.Throwable -> Lb5
|
|
java.util.concurrent.atomic.AtomicReferenceArray<com.google.common.cache.ReferenceEntry<K, V>> r10 = r9.table // Catch: java.lang.Throwable -> Lb5
|
|
int r1 = r10.length() // Catch: java.lang.Throwable -> Lb5
|
|
r11 = 1
|
|
int r1 = r1 - r11
|
|
r12 = r0 & r1
|
|
java.lang.Object r1 = r10.get(r12) // Catch: java.lang.Throwable -> Lb5
|
|
r2 = r1
|
|
com.google.common.cache.ReferenceEntry r2 = (com.google.common.cache.ReferenceEntry) r2 // Catch: java.lang.Throwable -> Lb5
|
|
r13 = r2
|
|
L24:
|
|
if (r13 == 0) goto Lad
|
|
java.lang.Object r4 = r13.getKey() // Catch: java.lang.Throwable -> Lb5
|
|
int r1 = r13.getHash() // Catch: java.lang.Throwable -> Lb5
|
|
if (r1 != r0) goto La3
|
|
if (r4 == 0) goto La3
|
|
com.google.common.cache.LocalCache<K, V> r1 = r9.map // Catch: java.lang.Throwable -> Lb5
|
|
com.google.common.base.Equivalence<java.lang.Object> r1 = r1.keyEquivalence // Catch: java.lang.Throwable -> Lb5
|
|
r14 = r17
|
|
boolean r1 = r1.equivalent(r14, r4) // Catch: java.lang.Throwable -> Lb5
|
|
if (r1 == 0) goto La5
|
|
com.google.common.cache.LocalCache$ValueReference r15 = r13.getValueReference() // Catch: java.lang.Throwable -> Lb5
|
|
java.lang.Object r6 = r15.get() // Catch: java.lang.Throwable -> Lb5
|
|
if (r6 != 0) goto L68
|
|
boolean r1 = r15.isActive() // Catch: java.lang.Throwable -> Lb5
|
|
if (r1 == 0) goto Lad
|
|
int r1 = r9.modCount // Catch: java.lang.Throwable -> Lb5
|
|
int r1 = r1 + r11
|
|
r9.modCount = r1 // Catch: java.lang.Throwable -> Lb5
|
|
com.google.common.cache.RemovalCause r8 = com.google.common.cache.RemovalCause.COLLECTED // Catch: java.lang.Throwable -> Lb5
|
|
r1 = r16
|
|
r3 = r13
|
|
r5 = r18
|
|
r7 = r15
|
|
com.google.common.cache.ReferenceEntry r0 = r1.removeValueFromChain(r2, r3, r4, r5, r6, r7, r8) // Catch: java.lang.Throwable -> Lb5
|
|
int r1 = r9.count // Catch: java.lang.Throwable -> Lb5
|
|
r10.set(r12, r0) // Catch: java.lang.Throwable -> Lb5
|
|
int r1 = r1 - r11
|
|
r9.count = r1 // Catch: java.lang.Throwable -> Lb5
|
|
goto Lad
|
|
L68:
|
|
com.google.common.cache.LocalCache<K, V> r1 = r9.map // Catch: java.lang.Throwable -> Lb5
|
|
com.google.common.base.Equivalence<java.lang.Object> r1 = r1.valueEquivalence // Catch: java.lang.Throwable -> Lb5
|
|
r3 = r19
|
|
boolean r1 = r1.equivalent(r3, r6) // Catch: java.lang.Throwable -> Lb5
|
|
if (r1 == 0) goto L9f
|
|
int r1 = r9.modCount // Catch: java.lang.Throwable -> Lb5
|
|
int r1 = r1 + r11
|
|
r9.modCount = r1 // Catch: java.lang.Throwable -> Lb5
|
|
int r5 = r15.getWeight() // Catch: java.lang.Throwable -> Lb5
|
|
com.google.common.cache.RemovalCause r10 = com.google.common.cache.RemovalCause.REPLACED // Catch: java.lang.Throwable -> Lb5
|
|
r1 = r16
|
|
r2 = r17
|
|
r3 = r18
|
|
r4 = r6
|
|
r6 = r10
|
|
r1.enqueueNotification(r2, r3, r4, r5, r6) // Catch: java.lang.Throwable -> Lb5
|
|
r1 = r16
|
|
r2 = r13
|
|
r3 = r17
|
|
r4 = r20
|
|
r5 = r7
|
|
r1.setValue(r2, r3, r4, r5) // Catch: java.lang.Throwable -> Lb5
|
|
r9.evictEntries(r13) // Catch: java.lang.Throwable -> Lb5
|
|
r16.unlock()
|
|
r16.postWriteCleanup()
|
|
return r11
|
|
L9f:
|
|
r9.recordLockedRead(r13, r7) // Catch: java.lang.Throwable -> Lb5
|
|
goto Lad
|
|
La3:
|
|
r14 = r17
|
|
La5:
|
|
r3 = r19
|
|
com.google.common.cache.ReferenceEntry r13 = r13.getNext() // Catch: java.lang.Throwable -> Lb5
|
|
goto L24
|
|
Lad:
|
|
r16.unlock()
|
|
r16.postWriteCleanup()
|
|
r0 = 0
|
|
return r0
|
|
Lb5:
|
|
r0 = move-exception
|
|
r16.unlock()
|
|
r16.postWriteCleanup()
|
|
throw r0
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.common.cache.LocalCache.Segment.replace(java.lang.Object, int, java.lang.Object, java.lang.Object):boolean");
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:16:0x009d, code lost:
|
|
|
|
unlock();
|
|
postWriteCleanup();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:17:0x00a4, code lost:
|
|
|
|
return null;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
V replace(K r17, int r18, V r19) {
|
|
/*
|
|
r16 = this;
|
|
r9 = r16
|
|
r0 = r18
|
|
r16.lock()
|
|
com.google.common.cache.LocalCache<K, V> r1 = r9.map // Catch: java.lang.Throwable -> La5
|
|
com.google.common.base.Ticker r1 = r1.ticker // Catch: java.lang.Throwable -> La5
|
|
long r7 = r1.read() // Catch: java.lang.Throwable -> La5
|
|
r9.preWriteCleanup(r7) // Catch: java.lang.Throwable -> La5
|
|
java.util.concurrent.atomic.AtomicReferenceArray<com.google.common.cache.ReferenceEntry<K, V>> r10 = r9.table // Catch: java.lang.Throwable -> La5
|
|
int r1 = r10.length() // Catch: java.lang.Throwable -> La5
|
|
int r1 = r1 + (-1)
|
|
r11 = r0 & r1
|
|
java.lang.Object r1 = r10.get(r11) // Catch: java.lang.Throwable -> La5
|
|
r2 = r1
|
|
com.google.common.cache.ReferenceEntry r2 = (com.google.common.cache.ReferenceEntry) r2 // Catch: java.lang.Throwable -> La5
|
|
r12 = r2
|
|
L24:
|
|
if (r12 == 0) goto L9d
|
|
java.lang.Object r4 = r12.getKey() // Catch: java.lang.Throwable -> La5
|
|
int r1 = r12.getHash() // Catch: java.lang.Throwable -> La5
|
|
if (r1 != r0) goto L96
|
|
if (r4 == 0) goto L96
|
|
com.google.common.cache.LocalCache<K, V> r1 = r9.map // Catch: java.lang.Throwable -> La5
|
|
com.google.common.base.Equivalence<java.lang.Object> r1 = r1.keyEquivalence // Catch: java.lang.Throwable -> La5
|
|
r13 = r17
|
|
boolean r1 = r1.equivalent(r13, r4) // Catch: java.lang.Throwable -> La5
|
|
if (r1 == 0) goto L98
|
|
com.google.common.cache.LocalCache$ValueReference r14 = r12.getValueReference() // Catch: java.lang.Throwable -> La5
|
|
java.lang.Object r15 = r14.get() // Catch: java.lang.Throwable -> La5
|
|
if (r15 != 0) goto L6b
|
|
boolean r1 = r14.isActive() // Catch: java.lang.Throwable -> La5
|
|
if (r1 == 0) goto L9d
|
|
int r1 = r9.modCount // Catch: java.lang.Throwable -> La5
|
|
int r1 = r1 + 1
|
|
r9.modCount = r1 // Catch: java.lang.Throwable -> La5
|
|
com.google.common.cache.RemovalCause r8 = com.google.common.cache.RemovalCause.COLLECTED // Catch: java.lang.Throwable -> La5
|
|
r1 = r16
|
|
r3 = r12
|
|
r5 = r18
|
|
r6 = r15
|
|
r7 = r14
|
|
com.google.common.cache.ReferenceEntry r0 = r1.removeValueFromChain(r2, r3, r4, r5, r6, r7, r8) // Catch: java.lang.Throwable -> La5
|
|
int r1 = r9.count // Catch: java.lang.Throwable -> La5
|
|
r10.set(r11, r0) // Catch: java.lang.Throwable -> La5
|
|
int r1 = r1 + (-1)
|
|
r9.count = r1 // Catch: java.lang.Throwable -> La5
|
|
goto L9d
|
|
L6b:
|
|
int r1 = r9.modCount // Catch: java.lang.Throwable -> La5
|
|
int r1 = r1 + 1
|
|
r9.modCount = r1 // Catch: java.lang.Throwable -> La5
|
|
int r5 = r14.getWeight() // Catch: java.lang.Throwable -> La5
|
|
com.google.common.cache.RemovalCause r6 = com.google.common.cache.RemovalCause.REPLACED // Catch: java.lang.Throwable -> La5
|
|
r1 = r16
|
|
r2 = r17
|
|
r3 = r18
|
|
r4 = r15
|
|
r1.enqueueNotification(r2, r3, r4, r5, r6) // Catch: java.lang.Throwable -> La5
|
|
r1 = r16
|
|
r2 = r12
|
|
r3 = r17
|
|
r4 = r19
|
|
r5 = r7
|
|
r1.setValue(r2, r3, r4, r5) // Catch: java.lang.Throwable -> La5
|
|
r9.evictEntries(r12) // Catch: java.lang.Throwable -> La5
|
|
r16.unlock()
|
|
r16.postWriteCleanup()
|
|
return r15
|
|
L96:
|
|
r13 = r17
|
|
L98:
|
|
com.google.common.cache.ReferenceEntry r12 = r12.getNext() // Catch: java.lang.Throwable -> La5
|
|
goto L24
|
|
L9d:
|
|
r16.unlock()
|
|
r16.postWriteCleanup()
|
|
r0 = 0
|
|
return r0
|
|
La5:
|
|
r0 = move-exception
|
|
r16.unlock()
|
|
r16.postWriteCleanup()
|
|
throw r0
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.common.cache.LocalCache.Segment.replace(java.lang.Object, int, java.lang.Object):java.lang.Object");
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:11:0x0037, code lost:
|
|
|
|
r9 = r5.getValueReference();
|
|
r12 = r9.get();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:12:0x003f, code lost:
|
|
|
|
if (r12 == null) goto L14;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:13:0x0041, code lost:
|
|
|
|
r2 = com.google.common.cache.RemovalCause.EXPLICIT;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:14:0x0043, code lost:
|
|
|
|
r10 = r2;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:15:0x004e, code lost:
|
|
|
|
r11.modCount++;
|
|
r13 = removeValueFromChain(r4, r5, r6, r13, r12, r9, r10);
|
|
r2 = r11.count;
|
|
r0.set(r1, r13);
|
|
r11.count = r2 - 1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:17:0x006a, code lost:
|
|
|
|
return r12;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:21:0x0049, code lost:
|
|
|
|
if (r9.isActive() == false) goto L22;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:22:0x004b, code lost:
|
|
|
|
r2 = com.google.common.cache.RemovalCause.COLLECTED;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
V remove(java.lang.Object r12, int r13) {
|
|
/*
|
|
r11 = this;
|
|
r11.lock()
|
|
com.google.common.cache.LocalCache<K, V> r0 = r11.map // Catch: java.lang.Throwable -> L78
|
|
com.google.common.base.Ticker r0 = r0.ticker // Catch: java.lang.Throwable -> L78
|
|
long r0 = r0.read() // Catch: java.lang.Throwable -> L78
|
|
r11.preWriteCleanup(r0) // Catch: java.lang.Throwable -> L78
|
|
java.util.concurrent.atomic.AtomicReferenceArray<com.google.common.cache.ReferenceEntry<K, V>> r0 = r11.table // Catch: java.lang.Throwable -> L78
|
|
int r1 = r0.length() // Catch: java.lang.Throwable -> L78
|
|
int r1 = r1 + (-1)
|
|
r1 = r1 & r13
|
|
java.lang.Object r2 = r0.get(r1) // Catch: java.lang.Throwable -> L78
|
|
r4 = r2
|
|
com.google.common.cache.ReferenceEntry r4 = (com.google.common.cache.ReferenceEntry) r4 // Catch: java.lang.Throwable -> L78
|
|
r5 = r4
|
|
L1f:
|
|
if (r5 == 0) goto L70
|
|
java.lang.Object r6 = r5.getKey() // Catch: java.lang.Throwable -> L78
|
|
int r2 = r5.getHash() // Catch: java.lang.Throwable -> L78
|
|
if (r2 != r13) goto L6b
|
|
if (r6 == 0) goto L6b
|
|
com.google.common.cache.LocalCache<K, V> r2 = r11.map // Catch: java.lang.Throwable -> L78
|
|
com.google.common.base.Equivalence<java.lang.Object> r2 = r2.keyEquivalence // Catch: java.lang.Throwable -> L78
|
|
boolean r2 = r2.equivalent(r12, r6) // Catch: java.lang.Throwable -> L78
|
|
if (r2 == 0) goto L6b
|
|
com.google.common.cache.LocalCache$ValueReference r9 = r5.getValueReference() // Catch: java.lang.Throwable -> L78
|
|
java.lang.Object r12 = r9.get() // Catch: java.lang.Throwable -> L78
|
|
if (r12 == 0) goto L45
|
|
com.google.common.cache.RemovalCause r2 = com.google.common.cache.RemovalCause.EXPLICIT // Catch: java.lang.Throwable -> L78
|
|
L43:
|
|
r10 = r2
|
|
goto L4e
|
|
L45:
|
|
boolean r2 = r9.isActive() // Catch: java.lang.Throwable -> L78
|
|
if (r2 == 0) goto L70
|
|
com.google.common.cache.RemovalCause r2 = com.google.common.cache.RemovalCause.COLLECTED // Catch: java.lang.Throwable -> L78
|
|
goto L43
|
|
L4e:
|
|
int r2 = r11.modCount // Catch: java.lang.Throwable -> L78
|
|
int r2 = r2 + 1
|
|
r11.modCount = r2 // Catch: java.lang.Throwable -> L78
|
|
r3 = r11
|
|
r7 = r13
|
|
r8 = r12
|
|
com.google.common.cache.ReferenceEntry r13 = r3.removeValueFromChain(r4, r5, r6, r7, r8, r9, r10) // Catch: java.lang.Throwable -> L78
|
|
int r2 = r11.count // Catch: java.lang.Throwable -> L78
|
|
r0.set(r1, r13) // Catch: java.lang.Throwable -> L78
|
|
int r2 = r2 + (-1)
|
|
r11.count = r2 // Catch: java.lang.Throwable -> L78
|
|
r11.unlock()
|
|
r11.postWriteCleanup()
|
|
return r12
|
|
L6b:
|
|
com.google.common.cache.ReferenceEntry r5 = r5.getNext() // Catch: java.lang.Throwable -> L78
|
|
goto L1f
|
|
L70:
|
|
r11.unlock()
|
|
r11.postWriteCleanup()
|
|
r12 = 0
|
|
return r12
|
|
L78:
|
|
r12 = move-exception
|
|
r11.unlock()
|
|
r11.postWriteCleanup()
|
|
throw r12
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.common.cache.LocalCache.Segment.remove(java.lang.Object, int):java.lang.Object");
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:12:0x0038, code lost:
|
|
|
|
r10 = r6.getValueReference();
|
|
r9 = r10.get();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:13:0x0048, code lost:
|
|
|
|
if (r12.map.valueEquivalence.equivalent(r15, r9) == false) goto L14;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:14:0x004a, code lost:
|
|
|
|
r13 = com.google.common.cache.RemovalCause.EXPLICIT;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:15:0x0057, code lost:
|
|
|
|
r12.modCount++;
|
|
r14 = removeValueFromChain(r5, r6, r7, r14, r9, r10, r13);
|
|
r15 = r12.count;
|
|
r0.set(r1, r14);
|
|
r12.count = r15 - 1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:16:0x006d, code lost:
|
|
|
|
if (r13 == com.google.common.cache.RemovalCause.EXPLICIT) goto L21;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:17:0x006f, code lost:
|
|
|
|
r2 = false;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:19:0x0076, code lost:
|
|
|
|
return r2;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:22:0x004d, code lost:
|
|
|
|
if (r9 != null) goto L25;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:24:0x0053, code lost:
|
|
|
|
if (r10.isActive() == false) goto L25;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:25:0x0055, code lost:
|
|
|
|
r13 = com.google.common.cache.RemovalCause.COLLECTED;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
boolean remove(java.lang.Object r13, int r14, java.lang.Object r15) {
|
|
/*
|
|
r12 = this;
|
|
r12.lock()
|
|
com.google.common.cache.LocalCache<K, V> r0 = r12.map // Catch: java.lang.Throwable -> L83
|
|
com.google.common.base.Ticker r0 = r0.ticker // Catch: java.lang.Throwable -> L83
|
|
long r0 = r0.read() // Catch: java.lang.Throwable -> L83
|
|
r12.preWriteCleanup(r0) // Catch: java.lang.Throwable -> L83
|
|
java.util.concurrent.atomic.AtomicReferenceArray<com.google.common.cache.ReferenceEntry<K, V>> r0 = r12.table // Catch: java.lang.Throwable -> L83
|
|
int r1 = r0.length() // Catch: java.lang.Throwable -> L83
|
|
r2 = 1
|
|
int r1 = r1 - r2
|
|
r1 = r1 & r14
|
|
java.lang.Object r3 = r0.get(r1) // Catch: java.lang.Throwable -> L83
|
|
r5 = r3
|
|
com.google.common.cache.ReferenceEntry r5 = (com.google.common.cache.ReferenceEntry) r5 // Catch: java.lang.Throwable -> L83
|
|
r6 = r5
|
|
L1f:
|
|
r3 = 0
|
|
if (r6 == 0) goto L7c
|
|
java.lang.Object r7 = r6.getKey() // Catch: java.lang.Throwable -> L83
|
|
int r4 = r6.getHash() // Catch: java.lang.Throwable -> L83
|
|
if (r4 != r14) goto L77
|
|
if (r7 == 0) goto L77
|
|
com.google.common.cache.LocalCache<K, V> r4 = r12.map // Catch: java.lang.Throwable -> L83
|
|
com.google.common.base.Equivalence<java.lang.Object> r4 = r4.keyEquivalence // Catch: java.lang.Throwable -> L83
|
|
boolean r4 = r4.equivalent(r13, r7) // Catch: java.lang.Throwable -> L83
|
|
if (r4 == 0) goto L77
|
|
com.google.common.cache.LocalCache$ValueReference r10 = r6.getValueReference() // Catch: java.lang.Throwable -> L83
|
|
java.lang.Object r9 = r10.get() // Catch: java.lang.Throwable -> L83
|
|
com.google.common.cache.LocalCache<K, V> r13 = r12.map // Catch: java.lang.Throwable -> L83
|
|
com.google.common.base.Equivalence<java.lang.Object> r13 = r13.valueEquivalence // Catch: java.lang.Throwable -> L83
|
|
boolean r13 = r13.equivalent(r15, r9) // Catch: java.lang.Throwable -> L83
|
|
if (r13 == 0) goto L4d
|
|
com.google.common.cache.RemovalCause r13 = com.google.common.cache.RemovalCause.EXPLICIT // Catch: java.lang.Throwable -> L83
|
|
goto L57
|
|
L4d:
|
|
if (r9 != 0) goto L7c
|
|
boolean r13 = r10.isActive() // Catch: java.lang.Throwable -> L83
|
|
if (r13 == 0) goto L7c
|
|
com.google.common.cache.RemovalCause r13 = com.google.common.cache.RemovalCause.COLLECTED // Catch: java.lang.Throwable -> L83
|
|
L57:
|
|
int r15 = r12.modCount // Catch: java.lang.Throwable -> L83
|
|
int r15 = r15 + r2
|
|
r12.modCount = r15 // Catch: java.lang.Throwable -> L83
|
|
r4 = r12
|
|
r8 = r14
|
|
r11 = r13
|
|
com.google.common.cache.ReferenceEntry r14 = r4.removeValueFromChain(r5, r6, r7, r8, r9, r10, r11) // Catch: java.lang.Throwable -> L83
|
|
int r15 = r12.count // Catch: java.lang.Throwable -> L83
|
|
r0.set(r1, r14) // Catch: java.lang.Throwable -> L83
|
|
int r15 = r15 - r2
|
|
r12.count = r15 // Catch: java.lang.Throwable -> L83
|
|
com.google.common.cache.RemovalCause r14 = com.google.common.cache.RemovalCause.EXPLICIT // Catch: java.lang.Throwable -> L83
|
|
if (r13 == r14) goto L70
|
|
r2 = r3
|
|
L70:
|
|
r12.unlock()
|
|
r12.postWriteCleanup()
|
|
return r2
|
|
L77:
|
|
com.google.common.cache.ReferenceEntry r6 = r6.getNext() // Catch: java.lang.Throwable -> L83
|
|
goto L1f
|
|
L7c:
|
|
r12.unlock()
|
|
r12.postWriteCleanup()
|
|
return r3
|
|
L83:
|
|
r13 = move-exception
|
|
r12.unlock()
|
|
r12.postWriteCleanup()
|
|
throw r13
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.common.cache.LocalCache.Segment.remove(java.lang.Object, int, java.lang.Object):boolean");
|
|
}
|
|
|
|
boolean storeLoadedValue(K k, int i, LoadingValueReference<K, V> loadingValueReference, V v) {
|
|
lock();
|
|
try {
|
|
long read = this.map.ticker.read();
|
|
preWriteCleanup(read);
|
|
int i2 = this.count + 1;
|
|
if (i2 > this.threshold) {
|
|
expand();
|
|
i2 = this.count + 1;
|
|
}
|
|
int i3 = i2;
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = i & (atomicReferenceArray.length() - 1);
|
|
ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(length);
|
|
ReferenceEntry<K, V> referenceEntry2 = referenceEntry;
|
|
while (true) {
|
|
if (referenceEntry2 != null) {
|
|
K key = referenceEntry2.getKey();
|
|
if (referenceEntry2.getHash() != i || key == null || !this.map.keyEquivalence.equivalent(k, key)) {
|
|
referenceEntry2 = referenceEntry2.getNext();
|
|
} else {
|
|
ValueReference<K, V> valueReference = referenceEntry2.getValueReference();
|
|
V v2 = valueReference.get();
|
|
if (loadingValueReference != valueReference && (v2 != null || valueReference == LocalCache.UNSET)) {
|
|
enqueueNotification(k, i, v, 0, RemovalCause.REPLACED);
|
|
unlock();
|
|
postWriteCleanup();
|
|
return false;
|
|
}
|
|
this.modCount++;
|
|
if (loadingValueReference.isActive()) {
|
|
enqueueNotification(k, i, v2, loadingValueReference.getWeight(), v2 == null ? RemovalCause.COLLECTED : RemovalCause.REPLACED);
|
|
i3--;
|
|
}
|
|
setValue(referenceEntry2, k, v, read);
|
|
this.count = i3;
|
|
evictEntries(referenceEntry2);
|
|
}
|
|
} else {
|
|
this.modCount++;
|
|
ReferenceEntry<K, V> newEntry = newEntry(k, i, referenceEntry);
|
|
setValue(newEntry, k, v, read);
|
|
atomicReferenceArray.set(length, newEntry);
|
|
this.count = i3;
|
|
evictEntries(newEntry);
|
|
break;
|
|
}
|
|
}
|
|
return true;
|
|
} finally {
|
|
unlock();
|
|
postWriteCleanup();
|
|
}
|
|
}
|
|
|
|
void clear() {
|
|
if (this.count != 0) {
|
|
lock();
|
|
try {
|
|
preWriteCleanup(this.map.ticker.read());
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
for (int i = 0; i < atomicReferenceArray.length(); i++) {
|
|
for (ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(i); referenceEntry != null; referenceEntry = referenceEntry.getNext()) {
|
|
if (referenceEntry.getValueReference().isActive()) {
|
|
K key = referenceEntry.getKey();
|
|
V v = referenceEntry.getValueReference().get();
|
|
enqueueNotification(key, referenceEntry.getHash(), v, referenceEntry.getValueReference().getWeight(), (key == null || v == null) ? RemovalCause.COLLECTED : RemovalCause.EXPLICIT);
|
|
}
|
|
}
|
|
}
|
|
for (int i2 = 0; i2 < atomicReferenceArray.length(); i2++) {
|
|
atomicReferenceArray.set(i2, null);
|
|
}
|
|
clearReferenceQueues();
|
|
this.writeQueue.clear();
|
|
this.accessQueue.clear();
|
|
this.readCount.set(0);
|
|
this.modCount++;
|
|
this.count = 0;
|
|
} finally {
|
|
unlock();
|
|
postWriteCleanup();
|
|
}
|
|
}
|
|
}
|
|
|
|
ReferenceEntry<K, V> removeValueFromChain(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2, K k, int i, V v, ValueReference<K, V> valueReference, RemovalCause removalCause) {
|
|
enqueueNotification(k, i, v, valueReference.getWeight(), removalCause);
|
|
this.writeQueue.remove(referenceEntry2);
|
|
this.accessQueue.remove(referenceEntry2);
|
|
if (valueReference.isLoading()) {
|
|
valueReference.notifyNewValue(null);
|
|
return referenceEntry;
|
|
}
|
|
return removeEntryFromChain(referenceEntry, referenceEntry2);
|
|
}
|
|
|
|
ReferenceEntry<K, V> removeEntryFromChain(ReferenceEntry<K, V> referenceEntry, ReferenceEntry<K, V> referenceEntry2) {
|
|
int i = this.count;
|
|
ReferenceEntry<K, V> next = referenceEntry2.getNext();
|
|
while (referenceEntry != referenceEntry2) {
|
|
ReferenceEntry<K, V> copyEntry = copyEntry(referenceEntry, next);
|
|
if (copyEntry != null) {
|
|
next = copyEntry;
|
|
} else {
|
|
removeCollectedEntry(referenceEntry);
|
|
i--;
|
|
}
|
|
referenceEntry = referenceEntry.getNext();
|
|
}
|
|
this.count = i;
|
|
return next;
|
|
}
|
|
|
|
void removeCollectedEntry(ReferenceEntry<K, V> referenceEntry) {
|
|
enqueueNotification(referenceEntry.getKey(), referenceEntry.getHash(), referenceEntry.getValueReference().get(), referenceEntry.getValueReference().getWeight(), RemovalCause.COLLECTED);
|
|
this.writeQueue.remove(referenceEntry);
|
|
this.accessQueue.remove(referenceEntry);
|
|
}
|
|
|
|
boolean reclaimKey(ReferenceEntry<K, V> referenceEntry, int i) {
|
|
lock();
|
|
try {
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = (atomicReferenceArray.length() - 1) & i;
|
|
ReferenceEntry<K, V> referenceEntry2 = atomicReferenceArray.get(length);
|
|
for (ReferenceEntry<K, V> referenceEntry3 = referenceEntry2; referenceEntry3 != null; referenceEntry3 = referenceEntry3.getNext()) {
|
|
if (referenceEntry3 == referenceEntry) {
|
|
this.modCount++;
|
|
ReferenceEntry<K, V> removeValueFromChain = removeValueFromChain(referenceEntry2, referenceEntry3, referenceEntry3.getKey(), i, referenceEntry3.getValueReference().get(), referenceEntry3.getValueReference(), RemovalCause.COLLECTED);
|
|
int i2 = this.count;
|
|
atomicReferenceArray.set(length, removeValueFromChain);
|
|
this.count = i2 - 1;
|
|
return true;
|
|
}
|
|
}
|
|
unlock();
|
|
postWriteCleanup();
|
|
return false;
|
|
} finally {
|
|
unlock();
|
|
postWriteCleanup();
|
|
}
|
|
}
|
|
|
|
boolean reclaimValue(K k, int i, ValueReference<K, V> valueReference) {
|
|
lock();
|
|
try {
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = (atomicReferenceArray.length() - 1) & i;
|
|
ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(length);
|
|
for (ReferenceEntry<K, V> referenceEntry2 = referenceEntry; referenceEntry2 != null; referenceEntry2 = referenceEntry2.getNext()) {
|
|
K key = referenceEntry2.getKey();
|
|
if (referenceEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
|
|
if (referenceEntry2.getValueReference() != valueReference) {
|
|
unlock();
|
|
if (!isHeldByCurrentThread()) {
|
|
postWriteCleanup();
|
|
}
|
|
return false;
|
|
}
|
|
this.modCount++;
|
|
ReferenceEntry<K, V> removeValueFromChain = removeValueFromChain(referenceEntry, referenceEntry2, key, i, valueReference.get(), valueReference, RemovalCause.COLLECTED);
|
|
int i2 = this.count;
|
|
atomicReferenceArray.set(length, removeValueFromChain);
|
|
this.count = i2 - 1;
|
|
return true;
|
|
}
|
|
}
|
|
unlock();
|
|
if (!isHeldByCurrentThread()) {
|
|
postWriteCleanup();
|
|
}
|
|
return false;
|
|
} finally {
|
|
unlock();
|
|
if (!isHeldByCurrentThread()) {
|
|
postWriteCleanup();
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean removeLoadingValue(K k, int i, LoadingValueReference<K, V> loadingValueReference) {
|
|
lock();
|
|
try {
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = (atomicReferenceArray.length() - 1) & i;
|
|
ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(length);
|
|
ReferenceEntry<K, V> referenceEntry2 = referenceEntry;
|
|
while (true) {
|
|
if (referenceEntry2 == null) {
|
|
break;
|
|
}
|
|
K key = referenceEntry2.getKey();
|
|
if (referenceEntry2.getHash() != i || key == null || !this.map.keyEquivalence.equivalent(k, key)) {
|
|
referenceEntry2 = referenceEntry2.getNext();
|
|
} else if (referenceEntry2.getValueReference() == loadingValueReference) {
|
|
if (loadingValueReference.isActive()) {
|
|
referenceEntry2.setValueReference(loadingValueReference.getOldValue());
|
|
} else {
|
|
atomicReferenceArray.set(length, removeEntryFromChain(referenceEntry, referenceEntry2));
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
unlock();
|
|
postWriteCleanup();
|
|
return false;
|
|
} finally {
|
|
unlock();
|
|
postWriteCleanup();
|
|
}
|
|
}
|
|
|
|
boolean removeEntry(ReferenceEntry<K, V> referenceEntry, int i, RemovalCause removalCause) {
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.table;
|
|
int length = (atomicReferenceArray.length() - 1) & i;
|
|
ReferenceEntry<K, V> referenceEntry2 = atomicReferenceArray.get(length);
|
|
for (ReferenceEntry<K, V> referenceEntry3 = referenceEntry2; referenceEntry3 != null; referenceEntry3 = referenceEntry3.getNext()) {
|
|
if (referenceEntry3 == referenceEntry) {
|
|
this.modCount++;
|
|
ReferenceEntry<K, V> removeValueFromChain = removeValueFromChain(referenceEntry2, referenceEntry3, referenceEntry3.getKey(), i, referenceEntry3.getValueReference().get(), referenceEntry3.getValueReference(), removalCause);
|
|
int i2 = this.count;
|
|
atomicReferenceArray.set(length, removeValueFromChain);
|
|
this.count = i2 - 1;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void postReadCleanup() {
|
|
if ((this.readCount.incrementAndGet() & 63) == 0) {
|
|
cleanUp();
|
|
}
|
|
}
|
|
|
|
void preWriteCleanup(long j) {
|
|
runLockedCleanup(j);
|
|
}
|
|
|
|
void postWriteCleanup() {
|
|
runUnlockedCleanup();
|
|
}
|
|
|
|
void cleanUp() {
|
|
runLockedCleanup(this.map.ticker.read());
|
|
runUnlockedCleanup();
|
|
}
|
|
|
|
void runLockedCleanup(long j) {
|
|
if (tryLock()) {
|
|
try {
|
|
drainReferenceQueues();
|
|
expireEntries(j);
|
|
this.readCount.set(0);
|
|
} finally {
|
|
unlock();
|
|
}
|
|
}
|
|
}
|
|
|
|
void runUnlockedCleanup() {
|
|
if (isHeldByCurrentThread()) {
|
|
return;
|
|
}
|
|
this.map.processPendingNotifications();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class LoadingValueReference<K, V> implements ValueReference<K, V> {
|
|
final SettableFuture<V> futureValue;
|
|
volatile ValueReference<K, V> oldValue;
|
|
final Stopwatch stopwatch;
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ValueReference<K, V> copyFor(ReferenceQueue<V> referenceQueue, V v, ReferenceEntry<K, V> referenceEntry) {
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public ReferenceEntry<K, V> getEntry() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isLoading() {
|
|
return true;
|
|
}
|
|
|
|
public LoadingValueReference() {
|
|
this(LocalCache.unset());
|
|
}
|
|
|
|
public LoadingValueReference(ValueReference<K, V> valueReference) {
|
|
this.futureValue = SettableFuture.create();
|
|
this.stopwatch = Stopwatch.createUnstarted();
|
|
this.oldValue = valueReference;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public boolean isActive() {
|
|
return this.oldValue.isActive();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public int getWeight() {
|
|
return this.oldValue.getWeight();
|
|
}
|
|
|
|
public boolean set(V v) {
|
|
return this.futureValue.set(v);
|
|
}
|
|
|
|
public boolean setException(Throwable th) {
|
|
return this.futureValue.setException(th);
|
|
}
|
|
|
|
private ListenableFuture<V> fullyFailedFuture(Throwable th) {
|
|
return Futures.immediateFailedFuture(th);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public void notifyNewValue(V v) {
|
|
if (v != null) {
|
|
set(v);
|
|
} else {
|
|
this.oldValue = LocalCache.unset();
|
|
}
|
|
}
|
|
|
|
public ListenableFuture<V> loadFuture(K k, CacheLoader<? super K, V> cacheLoader) {
|
|
try {
|
|
this.stopwatch.start();
|
|
V v = this.oldValue.get();
|
|
if (v == null) {
|
|
V load = cacheLoader.load(k);
|
|
return set(load) ? this.futureValue : Futures.immediateFuture(load);
|
|
}
|
|
ListenableFuture<V> reload = cacheLoader.reload(k, v);
|
|
if (reload == null) {
|
|
return Futures.immediateFuture(null);
|
|
}
|
|
return Futures.transform(reload, new Function<V, V>(this) { // from class: com.google.common.cache.LocalCache.LoadingValueReference.1
|
|
final LoadingValueReference this$0;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public V apply(V v2) {
|
|
this.this$0.set(v2);
|
|
return v2;
|
|
}
|
|
}, MoreExecutors.directExecutor());
|
|
} catch (Throwable th) {
|
|
ListenableFuture<V> fullyFailedFuture = setException(th) ? this.futureValue : fullyFailedFuture(th);
|
|
if (th instanceof InterruptedException) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
return fullyFailedFuture;
|
|
}
|
|
}
|
|
|
|
public long elapsedNanos() {
|
|
return this.stopwatch.elapsed(TimeUnit.NANOSECONDS);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public V waitForValue() throws ExecutionException {
|
|
return (V) Uninterruptibles.getUninterruptibly(this.futureValue);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.ValueReference
|
|
public V get() {
|
|
return this.oldValue.get();
|
|
}
|
|
|
|
public ValueReference<K, V> getOldValue() {
|
|
return this.oldValue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class WriteQueue<K, V> extends AbstractQueue<ReferenceEntry<K, V>> {
|
|
final ReferenceEntry<K, V> head = new AbstractReferenceEntry<K, V>(this) { // from class: com.google.common.cache.LocalCache.WriteQueue.1
|
|
ReferenceEntry<K, V> nextWrite = this;
|
|
ReferenceEntry<K, V> previousWrite = this;
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public long getWriteTime() {
|
|
return Long.MAX_VALUE;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public void setWriteTime(long j) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public void setPreviousInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public void setNextInWriteQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextWrite = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getPreviousInWriteQueue() {
|
|
return this.previousWrite;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getNextInWriteQueue() {
|
|
return this.nextWrite;
|
|
}
|
|
};
|
|
|
|
WriteQueue() {
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public final boolean offer(ReferenceEntry<K, V> referenceEntry) {
|
|
LocalCache.connectWriteOrder(referenceEntry.getPreviousInWriteQueue(), referenceEntry.getNextInWriteQueue());
|
|
LocalCache.connectWriteOrder(this.head.getPreviousInWriteQueue(), referenceEntry);
|
|
LocalCache.connectWriteOrder(referenceEntry, this.head);
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public final ReferenceEntry<K, V> peek() {
|
|
ReferenceEntry<K, V> nextInWriteQueue = this.head.getNextInWriteQueue();
|
|
if (nextInWriteQueue == this.head) {
|
|
return null;
|
|
}
|
|
return nextInWriteQueue;
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public final ReferenceEntry<K, V> poll() {
|
|
ReferenceEntry<K, V> nextInWriteQueue = this.head.getNextInWriteQueue();
|
|
if (nextInWriteQueue == this.head) {
|
|
return null;
|
|
}
|
|
remove(nextInWriteQueue);
|
|
return nextInWriteQueue;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean remove(Object obj) {
|
|
ReferenceEntry referenceEntry = (ReferenceEntry) obj;
|
|
ReferenceEntry<K, V> previousInWriteQueue = referenceEntry.getPreviousInWriteQueue();
|
|
ReferenceEntry<K, V> nextInWriteQueue = referenceEntry.getNextInWriteQueue();
|
|
LocalCache.connectWriteOrder(previousInWriteQueue, nextInWriteQueue);
|
|
LocalCache.nullifyWriteOrder(referenceEntry);
|
|
return nextInWriteQueue != NullEntry.INSTANCE;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean contains(Object obj) {
|
|
return ((ReferenceEntry) obj).getNextInWriteQueue() != NullEntry.INSTANCE;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean isEmpty() {
|
|
return this.head.getNextInWriteQueue() == this.head;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final int size() {
|
|
int i = 0;
|
|
for (ReferenceEntry<K, V> nextInWriteQueue = this.head.getNextInWriteQueue(); nextInWriteQueue != this.head; nextInWriteQueue = nextInWriteQueue.getNextInWriteQueue()) {
|
|
i++;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // java.util.AbstractQueue, java.util.AbstractCollection, java.util.Collection
|
|
public final void clear() {
|
|
ReferenceEntry<K, V> nextInWriteQueue = this.head.getNextInWriteQueue();
|
|
while (true) {
|
|
ReferenceEntry<K, V> referenceEntry = this.head;
|
|
if (nextInWriteQueue != referenceEntry) {
|
|
ReferenceEntry<K, V> nextInWriteQueue2 = nextInWriteQueue.getNextInWriteQueue();
|
|
LocalCache.nullifyWriteOrder(nextInWriteQueue);
|
|
nextInWriteQueue = nextInWriteQueue2;
|
|
} else {
|
|
referenceEntry.setNextInWriteQueue(referenceEntry);
|
|
ReferenceEntry<K, V> referenceEntry2 = this.head;
|
|
referenceEntry2.setPreviousInWriteQueue(referenceEntry2);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
|
public final Iterator<ReferenceEntry<K, V>> iterator() {
|
|
return new AbstractSequentialIterator<ReferenceEntry<K, V>>(this, peek()) { // from class: com.google.common.cache.LocalCache.WriteQueue.2
|
|
final WriteQueue this$0;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.collect.AbstractSequentialIterator
|
|
public ReferenceEntry<K, V> computeNext(ReferenceEntry<K, V> referenceEntry) {
|
|
ReferenceEntry<K, V> nextInWriteQueue = referenceEntry.getNextInWriteQueue();
|
|
if (nextInWriteQueue == this.this$0.head) {
|
|
return null;
|
|
}
|
|
return nextInWriteQueue;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class AccessQueue<K, V> extends AbstractQueue<ReferenceEntry<K, V>> {
|
|
final ReferenceEntry<K, V> head = new AbstractReferenceEntry<K, V>(this) { // from class: com.google.common.cache.LocalCache.AccessQueue.1
|
|
ReferenceEntry<K, V> nextAccess = this;
|
|
ReferenceEntry<K, V> previousAccess = this;
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public long getAccessTime() {
|
|
return Long.MAX_VALUE;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public void setAccessTime(long j) {
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public void setPreviousInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.previousAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public void setNextInAccessQueue(ReferenceEntry<K, V> referenceEntry) {
|
|
this.nextAccess = referenceEntry;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getPreviousInAccessQueue() {
|
|
return this.previousAccess;
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.AbstractReferenceEntry, com.google.common.cache.ReferenceEntry
|
|
public ReferenceEntry<K, V> getNextInAccessQueue() {
|
|
return this.nextAccess;
|
|
}
|
|
};
|
|
|
|
AccessQueue() {
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public final boolean offer(ReferenceEntry<K, V> referenceEntry) {
|
|
LocalCache.connectAccessOrder(referenceEntry.getPreviousInAccessQueue(), referenceEntry.getNextInAccessQueue());
|
|
LocalCache.connectAccessOrder(this.head.getPreviousInAccessQueue(), referenceEntry);
|
|
LocalCache.connectAccessOrder(referenceEntry, this.head);
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public final ReferenceEntry<K, V> peek() {
|
|
ReferenceEntry<K, V> nextInAccessQueue = this.head.getNextInAccessQueue();
|
|
if (nextInAccessQueue == this.head) {
|
|
return null;
|
|
}
|
|
return nextInAccessQueue;
|
|
}
|
|
|
|
@Override // java.util.Queue
|
|
public final ReferenceEntry<K, V> poll() {
|
|
ReferenceEntry<K, V> nextInAccessQueue = this.head.getNextInAccessQueue();
|
|
if (nextInAccessQueue == this.head) {
|
|
return null;
|
|
}
|
|
remove(nextInAccessQueue);
|
|
return nextInAccessQueue;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean remove(Object obj) {
|
|
ReferenceEntry referenceEntry = (ReferenceEntry) obj;
|
|
ReferenceEntry<K, V> previousInAccessQueue = referenceEntry.getPreviousInAccessQueue();
|
|
ReferenceEntry<K, V> nextInAccessQueue = referenceEntry.getNextInAccessQueue();
|
|
LocalCache.connectAccessOrder(previousInAccessQueue, nextInAccessQueue);
|
|
LocalCache.nullifyAccessOrder(referenceEntry);
|
|
return nextInAccessQueue != NullEntry.INSTANCE;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean contains(Object obj) {
|
|
return ((ReferenceEntry) obj).getNextInAccessQueue() != NullEntry.INSTANCE;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean isEmpty() {
|
|
return this.head.getNextInAccessQueue() == this.head;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final int size() {
|
|
int i = 0;
|
|
for (ReferenceEntry<K, V> nextInAccessQueue = this.head.getNextInAccessQueue(); nextInAccessQueue != this.head; nextInAccessQueue = nextInAccessQueue.getNextInAccessQueue()) {
|
|
i++;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // java.util.AbstractQueue, java.util.AbstractCollection, java.util.Collection
|
|
public final void clear() {
|
|
ReferenceEntry<K, V> nextInAccessQueue = this.head.getNextInAccessQueue();
|
|
while (true) {
|
|
ReferenceEntry<K, V> referenceEntry = this.head;
|
|
if (nextInAccessQueue != referenceEntry) {
|
|
ReferenceEntry<K, V> nextInAccessQueue2 = nextInAccessQueue.getNextInAccessQueue();
|
|
LocalCache.nullifyAccessOrder(nextInAccessQueue);
|
|
nextInAccessQueue = nextInAccessQueue2;
|
|
} else {
|
|
referenceEntry.setNextInAccessQueue(referenceEntry);
|
|
ReferenceEntry<K, V> referenceEntry2 = this.head;
|
|
referenceEntry2.setPreviousInAccessQueue(referenceEntry2);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
|
public final Iterator<ReferenceEntry<K, V>> iterator() {
|
|
return new AbstractSequentialIterator<ReferenceEntry<K, V>>(this, peek()) { // from class: com.google.common.cache.LocalCache.AccessQueue.2
|
|
final AccessQueue this$0;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.collect.AbstractSequentialIterator
|
|
public ReferenceEntry<K, V> computeNext(ReferenceEntry<K, V> referenceEntry) {
|
|
ReferenceEntry<K, V> nextInAccessQueue = referenceEntry.getNextInAccessQueue();
|
|
if (nextInAccessQueue == this.this$0.head) {
|
|
return null;
|
|
}
|
|
return nextInAccessQueue;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
public void cleanUp() {
|
|
for (Segment<K, V> segment : this.segments) {
|
|
segment.cleanUp();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean isEmpty() {
|
|
Segment<K, V>[] segmentArr = this.segments;
|
|
long j = 0;
|
|
for (int i = 0; i < segmentArr.length; i++) {
|
|
if (segmentArr[i].count != 0) {
|
|
return false;
|
|
}
|
|
j += segmentArr[i].modCount;
|
|
}
|
|
if (j == 0) {
|
|
return true;
|
|
}
|
|
for (int i2 = 0; i2 < segmentArr.length; i2++) {
|
|
if (segmentArr[i2].count != 0) {
|
|
return false;
|
|
}
|
|
j -= segmentArr[i2].modCount;
|
|
}
|
|
return j == 0;
|
|
}
|
|
|
|
long longSize() {
|
|
long j = 0;
|
|
for (int i = 0; i < this.segments.length; i++) {
|
|
j += Math.max(0, r0[i].count);
|
|
}
|
|
return j;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public int size() {
|
|
return Ints.saturatedCast(longSize());
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V get(Object obj) {
|
|
if (obj == null) {
|
|
return null;
|
|
}
|
|
int hash = hash(obj);
|
|
return segmentFor(hash).get(obj, hash);
|
|
}
|
|
|
|
V get(K k, CacheLoader<? super K, V> cacheLoader) throws ExecutionException {
|
|
int hash = hash(Preconditions.checkNotNull(k));
|
|
return segmentFor(hash).get(k, hash, cacheLoader);
|
|
}
|
|
|
|
public V getIfPresent(Object obj) {
|
|
int hash = hash(Preconditions.checkNotNull(obj));
|
|
V v = segmentFor(hash).get(obj, hash);
|
|
if (v == null) {
|
|
this.globalStatsCounter.recordMisses(1);
|
|
} else {
|
|
this.globalStatsCounter.recordHits(1);
|
|
}
|
|
return v;
|
|
}
|
|
|
|
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
|
|
public V getOrDefault(Object obj, V v) {
|
|
V v2 = get(obj);
|
|
return v2 != null ? v2 : v;
|
|
}
|
|
|
|
V getOrLoad(K k) throws ExecutionException {
|
|
return get(k, this.defaultLoader);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
ImmutableMap<K, V> getAllPresent(Iterable<?> iterable) {
|
|
LinkedHashMap newLinkedHashMap = Maps.newLinkedHashMap();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
for (Object obj : iterable) {
|
|
V v = get(obj);
|
|
if (v == null) {
|
|
i2++;
|
|
} else {
|
|
newLinkedHashMap.put(obj, v);
|
|
i++;
|
|
}
|
|
}
|
|
this.globalStatsCounter.recordHits(i);
|
|
this.globalStatsCounter.recordMisses(i2);
|
|
return ImmutableMap.copyOf((Map) newLinkedHashMap);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
ImmutableMap<K, V> getAll(Iterable<? extends K> iterable) throws ExecutionException {
|
|
LinkedHashMap newLinkedHashMap = Maps.newLinkedHashMap();
|
|
LinkedHashSet newLinkedHashSet = Sets.newLinkedHashSet();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
for (K k : iterable) {
|
|
Object obj = get(k);
|
|
if (!newLinkedHashMap.containsKey(k)) {
|
|
newLinkedHashMap.put(k, obj);
|
|
if (obj == null) {
|
|
i++;
|
|
newLinkedHashSet.add(k);
|
|
} else {
|
|
i2++;
|
|
}
|
|
}
|
|
}
|
|
try {
|
|
if (!newLinkedHashSet.isEmpty()) {
|
|
try {
|
|
Map loadAll = loadAll(newLinkedHashSet, this.defaultLoader);
|
|
for (Object obj2 : newLinkedHashSet) {
|
|
Object obj3 = loadAll.get(obj2);
|
|
if (obj3 == null) {
|
|
String valueOf = String.valueOf(obj2);
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 37);
|
|
sb.append("loadAll failed to return a value for ");
|
|
sb.append(valueOf);
|
|
throw new CacheLoader.InvalidCacheLoadException(sb.toString());
|
|
}
|
|
newLinkedHashMap.put(obj2, obj3);
|
|
}
|
|
} catch (CacheLoader.UnsupportedLoadingOperationException unused) {
|
|
for (Object obj4 : newLinkedHashSet) {
|
|
i--;
|
|
newLinkedHashMap.put(obj4, get(obj4, this.defaultLoader));
|
|
}
|
|
}
|
|
}
|
|
return ImmutableMap.copyOf((Map) newLinkedHashMap);
|
|
} finally {
|
|
this.globalStatsCounter.recordHits(i2);
|
|
this.globalStatsCounter.recordMisses(i);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:32:0x00d5 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
java.util.Map<K, V> loadAll(java.util.Set<? extends K> r7, com.google.common.cache.CacheLoader<? super K, V> r8) throws java.util.concurrent.ExecutionException {
|
|
/*
|
|
r6 = this;
|
|
com.google.common.base.Preconditions.checkNotNull(r8)
|
|
com.google.common.base.Preconditions.checkNotNull(r7)
|
|
com.google.common.base.Stopwatch r0 = com.google.common.base.Stopwatch.createStarted()
|
|
r1 = 1
|
|
r2 = 0
|
|
java.util.Map r7 = r8.loadAll(r7) // Catch: java.lang.Throwable -> La9 java.lang.Error -> Lab java.lang.Exception -> Lb2 java.lang.RuntimeException -> Lb9 java.lang.InterruptedException -> Lc0 com.google.common.cache.CacheLoader.UnsupportedLoadingOperationException -> Ld0
|
|
if (r7 == 0) goto L79
|
|
r0.stop()
|
|
java.util.Set r3 = r7.entrySet()
|
|
java.util.Iterator r3 = r3.iterator()
|
|
L1d:
|
|
boolean r4 = r3.hasNext()
|
|
if (r4 == 0) goto L3b
|
|
java.lang.Object r4 = r3.next()
|
|
java.util.Map$Entry r4 = (java.util.Map.Entry) r4
|
|
java.lang.Object r5 = r4.getKey()
|
|
java.lang.Object r4 = r4.getValue()
|
|
if (r5 == 0) goto L39
|
|
if (r4 == 0) goto L39
|
|
r6.put(r5, r4)
|
|
goto L1d
|
|
L39:
|
|
r2 = r1
|
|
goto L1d
|
|
L3b:
|
|
if (r2 != 0) goto L49
|
|
com.google.common.cache.AbstractCache$StatsCounter r8 = r6.globalStatsCounter
|
|
java.util.concurrent.TimeUnit r1 = java.util.concurrent.TimeUnit.NANOSECONDS
|
|
long r0 = r0.elapsed(r1)
|
|
r8.recordLoadSuccess(r0)
|
|
return r7
|
|
L49:
|
|
com.google.common.cache.AbstractCache$StatsCounter r7 = r6.globalStatsCounter
|
|
java.util.concurrent.TimeUnit r1 = java.util.concurrent.TimeUnit.NANOSECONDS
|
|
long r0 = r0.elapsed(r1)
|
|
r7.recordLoadException(r0)
|
|
java.lang.String r7 = java.lang.String.valueOf(r8)
|
|
com.google.common.cache.CacheLoader$InvalidCacheLoadException r8 = new com.google.common.cache.CacheLoader$InvalidCacheLoadException
|
|
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
|
java.lang.String r1 = java.lang.String.valueOf(r7)
|
|
int r1 = r1.length()
|
|
int r1 = r1 + 42
|
|
r0.<init>(r1)
|
|
r0.append(r7)
|
|
java.lang.String r7 = " returned null keys or values from loadAll"
|
|
r0.append(r7)
|
|
java.lang.String r7 = r0.toString()
|
|
r8.<init>(r7)
|
|
throw r8
|
|
L79:
|
|
com.google.common.cache.AbstractCache$StatsCounter r7 = r6.globalStatsCounter
|
|
java.util.concurrent.TimeUnit r1 = java.util.concurrent.TimeUnit.NANOSECONDS
|
|
long r0 = r0.elapsed(r1)
|
|
r7.recordLoadException(r0)
|
|
java.lang.String r7 = java.lang.String.valueOf(r8)
|
|
com.google.common.cache.CacheLoader$InvalidCacheLoadException r8 = new com.google.common.cache.CacheLoader$InvalidCacheLoadException
|
|
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
|
java.lang.String r1 = java.lang.String.valueOf(r7)
|
|
int r1 = r1.length()
|
|
int r1 = r1 + 31
|
|
r0.<init>(r1)
|
|
r0.append(r7)
|
|
java.lang.String r7 = " returned null map from loadAll"
|
|
r0.append(r7)
|
|
java.lang.String r7 = r0.toString()
|
|
r8.<init>(r7)
|
|
throw r8
|
|
La9:
|
|
r7 = move-exception
|
|
goto Lce
|
|
Lab:
|
|
r7 = move-exception
|
|
com.google.common.util.concurrent.ExecutionError r8 = new com.google.common.util.concurrent.ExecutionError // Catch: java.lang.Throwable -> La9
|
|
r8.<init>(r7) // Catch: java.lang.Throwable -> La9
|
|
throw r8 // Catch: java.lang.Throwable -> La9
|
|
Lb2:
|
|
r7 = move-exception
|
|
java.util.concurrent.ExecutionException r8 = new java.util.concurrent.ExecutionException // Catch: java.lang.Throwable -> La9
|
|
r8.<init>(r7) // Catch: java.lang.Throwable -> La9
|
|
throw r8 // Catch: java.lang.Throwable -> La9
|
|
Lb9:
|
|
r7 = move-exception
|
|
com.google.common.util.concurrent.UncheckedExecutionException r8 = new com.google.common.util.concurrent.UncheckedExecutionException // Catch: java.lang.Throwable -> La9
|
|
r8.<init>(r7) // Catch: java.lang.Throwable -> La9
|
|
throw r8 // Catch: java.lang.Throwable -> La9
|
|
Lc0:
|
|
r7 = move-exception
|
|
java.lang.Thread r8 = java.lang.Thread.currentThread() // Catch: java.lang.Throwable -> La9
|
|
r8.interrupt() // Catch: java.lang.Throwable -> La9
|
|
java.util.concurrent.ExecutionException r8 = new java.util.concurrent.ExecutionException // Catch: java.lang.Throwable -> La9
|
|
r8.<init>(r7) // Catch: java.lang.Throwable -> La9
|
|
throw r8 // Catch: java.lang.Throwable -> La9
|
|
Lce:
|
|
r1 = r2
|
|
goto Ld3
|
|
Ld0:
|
|
r7 = move-exception
|
|
throw r7 // Catch: java.lang.Throwable -> Ld2
|
|
Ld2:
|
|
r7 = move-exception
|
|
Ld3:
|
|
if (r1 != 0) goto Le0
|
|
com.google.common.cache.AbstractCache$StatsCounter r8 = r6.globalStatsCounter
|
|
java.util.concurrent.TimeUnit r1 = java.util.concurrent.TimeUnit.NANOSECONDS
|
|
long r0 = r0.elapsed(r1)
|
|
r8.recordLoadException(r0)
|
|
Le0:
|
|
throw r7
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.common.cache.LocalCache.loadAll(java.util.Set, com.google.common.cache.CacheLoader):java.util.Map");
|
|
}
|
|
|
|
ReferenceEntry<K, V> getEntry(Object obj) {
|
|
if (obj == null) {
|
|
return null;
|
|
}
|
|
int hash = hash(obj);
|
|
return segmentFor(hash).getEntry(obj, hash);
|
|
}
|
|
|
|
void refresh(K k) {
|
|
int hash = hash(Preconditions.checkNotNull(k));
|
|
segmentFor(hash).refresh(k, hash, this.defaultLoader, false);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
if (obj == null) {
|
|
return false;
|
|
}
|
|
int hash = hash(obj);
|
|
return segmentFor(hash).containsKey(obj, hash);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Type inference failed for: r12v0 */
|
|
/* JADX WARN: Type inference failed for: r12v1, types: [int] */
|
|
/* JADX WARN: Type inference failed for: r12v3 */
|
|
/* JADX WARN: Type inference failed for: r15v0 */
|
|
/* JADX WARN: Type inference failed for: r15v1, types: [int] */
|
|
/* JADX WARN: Type inference failed for: r15v3 */
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsValue(Object obj) {
|
|
boolean z = false;
|
|
if (obj == null) {
|
|
return false;
|
|
}
|
|
long read = this.ticker.read();
|
|
Segment<K, V>[] segmentArr = this.segments;
|
|
long j = -1;
|
|
int i = 0;
|
|
while (i < 3) {
|
|
int length = segmentArr.length;
|
|
long j2 = 0;
|
|
for (?? r12 = z; r12 < length; r12++) {
|
|
Segment<K, V> segment = segmentArr[r12];
|
|
int i2 = segment.count;
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = segment.table;
|
|
for (?? r15 = z; r15 < atomicReferenceArray.length(); r15++) {
|
|
ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(r15);
|
|
while (referenceEntry != null) {
|
|
Segment<K, V>[] segmentArr2 = segmentArr;
|
|
V liveValue = segment.getLiveValue(referenceEntry, read);
|
|
long j3 = read;
|
|
if (liveValue != null && this.valueEquivalence.equivalent(obj, liveValue)) {
|
|
return true;
|
|
}
|
|
referenceEntry = referenceEntry.getNext();
|
|
segmentArr = segmentArr2;
|
|
read = j3;
|
|
}
|
|
}
|
|
j2 += segment.modCount;
|
|
read = read;
|
|
z = false;
|
|
}
|
|
long j4 = read;
|
|
Segment<K, V>[] segmentArr3 = segmentArr;
|
|
if (j2 == j) {
|
|
return false;
|
|
}
|
|
i++;
|
|
j = j2;
|
|
segmentArr = segmentArr3;
|
|
read = j4;
|
|
z = false;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V put(K k, V v) {
|
|
Preconditions.checkNotNull(k);
|
|
Preconditions.checkNotNull(v);
|
|
int hash = hash(k);
|
|
return segmentFor(hash).put(k, hash, v, false);
|
|
}
|
|
|
|
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
|
|
public V putIfAbsent(K k, V v) {
|
|
Preconditions.checkNotNull(k);
|
|
Preconditions.checkNotNull(v);
|
|
int hash = hash(k);
|
|
return segmentFor(hash).put(k, hash, v, true);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public void putAll(Map<? extends K, ? extends V> map) {
|
|
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
|
put(entry.getKey(), entry.getValue());
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V remove(Object obj) {
|
|
if (obj == null) {
|
|
return null;
|
|
}
|
|
int hash = hash(obj);
|
|
return segmentFor(hash).remove(obj, hash);
|
|
}
|
|
|
|
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
|
|
public boolean remove(Object obj, Object obj2) {
|
|
if (obj == null || obj2 == null) {
|
|
return false;
|
|
}
|
|
int hash = hash(obj);
|
|
return segmentFor(hash).remove(obj, hash, obj2);
|
|
}
|
|
|
|
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
|
|
public boolean replace(K k, V v, V v2) {
|
|
Preconditions.checkNotNull(k);
|
|
Preconditions.checkNotNull(v2);
|
|
if (v == null) {
|
|
return false;
|
|
}
|
|
int hash = hash(k);
|
|
return segmentFor(hash).replace(k, hash, v, v2);
|
|
}
|
|
|
|
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
|
|
public V replace(K k, V v) {
|
|
Preconditions.checkNotNull(k);
|
|
Preconditions.checkNotNull(v);
|
|
int hash = hash(k);
|
|
return segmentFor(hash).replace(k, hash, v);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public void clear() {
|
|
for (Segment<K, V> segment : this.segments) {
|
|
segment.clear();
|
|
}
|
|
}
|
|
|
|
void invalidateAll(Iterable<?> iterable) {
|
|
Iterator<?> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
remove(it.next());
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Set<K> keySet() {
|
|
Set<K> set = this.keySet;
|
|
if (set != null) {
|
|
return set;
|
|
}
|
|
KeySet keySet = new KeySet(this);
|
|
this.keySet = keySet;
|
|
return keySet;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Collection<V> values() {
|
|
Collection<V> collection = this.values;
|
|
if (collection != null) {
|
|
return collection;
|
|
}
|
|
Values values = new Values(this);
|
|
this.values = values;
|
|
return values;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Set<Map.Entry<K, V>> entrySet() {
|
|
Set<Map.Entry<K, V>> set = this.entrySet;
|
|
if (set != null) {
|
|
return set;
|
|
}
|
|
EntrySet entrySet = new EntrySet(this);
|
|
this.entrySet = entrySet;
|
|
return entrySet;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public abstract class HashIterator<T> implements Iterator<T> {
|
|
Segment<K, V> currentSegment;
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> currentTable;
|
|
LocalCache<K, V>.WriteThroughEntry lastReturned;
|
|
ReferenceEntry<K, V> nextEntry;
|
|
LocalCache<K, V>.WriteThroughEntry nextExternal;
|
|
int nextSegmentIndex;
|
|
int nextTableIndex = -1;
|
|
final LocalCache this$0;
|
|
|
|
@Override // java.util.Iterator
|
|
public abstract T next();
|
|
|
|
HashIterator(LocalCache localCache) {
|
|
this.this$0 = localCache;
|
|
this.nextSegmentIndex = localCache.segments.length - 1;
|
|
advance();
|
|
}
|
|
|
|
final void advance() {
|
|
this.nextExternal = null;
|
|
if (nextInChain() || nextInTable()) {
|
|
return;
|
|
}
|
|
while (this.nextSegmentIndex >= 0) {
|
|
Segment<K, V>[] segmentArr = this.this$0.segments;
|
|
int i = this.nextSegmentIndex;
|
|
this.nextSegmentIndex = i - 1;
|
|
Segment<K, V> segment = segmentArr[i];
|
|
this.currentSegment = segment;
|
|
if (segment.count != 0) {
|
|
this.currentTable = this.currentSegment.table;
|
|
this.nextTableIndex = r0.length() - 1;
|
|
if (nextInTable()) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean nextInChain() {
|
|
ReferenceEntry<K, V> referenceEntry = this.nextEntry;
|
|
if (referenceEntry == null) {
|
|
return false;
|
|
}
|
|
while (true) {
|
|
ReferenceEntry<K, V> next = referenceEntry.getNext();
|
|
this.nextEntry = next;
|
|
if (next == null) {
|
|
return false;
|
|
}
|
|
if (advanceTo(next)) {
|
|
return true;
|
|
}
|
|
referenceEntry = this.nextEntry;
|
|
}
|
|
}
|
|
|
|
boolean nextInTable() {
|
|
while (true) {
|
|
int i = this.nextTableIndex;
|
|
if (i < 0) {
|
|
return false;
|
|
}
|
|
AtomicReferenceArray<ReferenceEntry<K, V>> atomicReferenceArray = this.currentTable;
|
|
this.nextTableIndex = i - 1;
|
|
ReferenceEntry<K, V> referenceEntry = atomicReferenceArray.get(i);
|
|
this.nextEntry = referenceEntry;
|
|
if (referenceEntry != null && (advanceTo(referenceEntry) || nextInChain())) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean advanceTo(ReferenceEntry<K, V> referenceEntry) {
|
|
try {
|
|
long read = this.this$0.ticker.read();
|
|
K key = referenceEntry.getKey();
|
|
Object liveValue = this.this$0.getLiveValue(referenceEntry, read);
|
|
if (liveValue == null) {
|
|
this.currentSegment.postReadCleanup();
|
|
return false;
|
|
}
|
|
this.nextExternal = new WriteThroughEntry(this.this$0, key, liveValue);
|
|
this.currentSegment.postReadCleanup();
|
|
return true;
|
|
} catch (Throwable th) {
|
|
this.currentSegment.postReadCleanup();
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
LocalCache<K, V>.WriteThroughEntry nextEntry() {
|
|
LocalCache<K, V>.WriteThroughEntry writeThroughEntry = this.nextExternal;
|
|
if (writeThroughEntry == null) {
|
|
throw new NoSuchElementException();
|
|
}
|
|
this.lastReturned = writeThroughEntry;
|
|
advance();
|
|
return this.lastReturned;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
Preconditions.checkState(this.lastReturned != null);
|
|
this.this$0.remove(this.lastReturned.getKey());
|
|
this.lastReturned = null;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.nextExternal != null;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class KeyIterator extends HashIterator {
|
|
KeyIterator(LocalCache localCache) {
|
|
super(localCache);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.HashIterator, java.util.Iterator
|
|
public final K next() {
|
|
return nextEntry().getKey();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class ValueIterator extends HashIterator {
|
|
ValueIterator(LocalCache localCache) {
|
|
super(localCache);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.HashIterator, java.util.Iterator
|
|
public final V next() {
|
|
return nextEntry().getValue();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public final class WriteThroughEntry implements Map.Entry<K, V> {
|
|
final K key;
|
|
final LocalCache this$0;
|
|
V value;
|
|
|
|
WriteThroughEntry(LocalCache localCache, K k, V v) {
|
|
this.this$0 = localCache;
|
|
this.key = k;
|
|
this.value = v;
|
|
}
|
|
|
|
@Override // java.util.Map.Entry
|
|
public final boolean equals(Object obj) {
|
|
if (!(obj instanceof Map.Entry)) {
|
|
return false;
|
|
}
|
|
Map.Entry entry = (Map.Entry) obj;
|
|
return this.key.equals(entry.getKey()) && this.value.equals(entry.getValue());
|
|
}
|
|
|
|
@Override // java.util.Map.Entry
|
|
public final int hashCode() {
|
|
return this.key.hashCode() ^ this.value.hashCode();
|
|
}
|
|
|
|
@Override // java.util.Map.Entry
|
|
public final V setValue(V v) {
|
|
V put = this.this$0.put(this.key, v);
|
|
this.value = v;
|
|
return put;
|
|
}
|
|
|
|
public final String toString() {
|
|
String valueOf = String.valueOf(getKey());
|
|
String valueOf2 = String.valueOf(getValue());
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 1 + String.valueOf(valueOf2).length());
|
|
sb.append(valueOf);
|
|
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
|
|
sb.append(valueOf2);
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // java.util.Map.Entry
|
|
public final V getValue() {
|
|
return this.value;
|
|
}
|
|
|
|
@Override // java.util.Map.Entry
|
|
public final K getKey() {
|
|
return this.key;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class EntryIterator extends HashIterator {
|
|
EntryIterator(LocalCache localCache) {
|
|
super(localCache);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.HashIterator, java.util.Iterator
|
|
public final Map.Entry<K, V> next() {
|
|
return nextEntry();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
abstract class AbstractCacheSet<T> extends AbstractSet<T> {
|
|
final LocalCache this$0;
|
|
|
|
AbstractCacheSet(LocalCache localCache) {
|
|
this.this$0 = localCache;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public int size() {
|
|
return this.this$0.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean isEmpty() {
|
|
return this.this$0.isEmpty();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public void clear() {
|
|
this.this$0.clear();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public Object[] toArray() {
|
|
return LocalCache.toArrayList(this).toArray();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public <E> E[] toArray(E[] eArr) {
|
|
return (E[]) LocalCache.toArrayList(this).toArray(eArr);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static <E> ArrayList<E> toArrayList(Collection<E> collection) {
|
|
ArrayList<E> arrayList = new ArrayList<>(collection.size());
|
|
Iterators.addAll(arrayList, collection.iterator());
|
|
return arrayList;
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class KeySet extends AbstractCacheSet {
|
|
final LocalCache this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
KeySet(LocalCache localCache) {
|
|
super(localCache);
|
|
this.this$0 = localCache;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public final Iterator<K> iterator() {
|
|
return new KeyIterator(this.this$0);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public final boolean contains(Object obj) {
|
|
return this.this$0.containsKey(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public final boolean remove(Object obj) {
|
|
return this.this$0.remove(obj) != null;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class Values extends AbstractCollection<V> {
|
|
final LocalCache this$0;
|
|
|
|
Values(LocalCache localCache) {
|
|
this.this$0 = localCache;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final int size() {
|
|
return this.this$0.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean isEmpty() {
|
|
return this.this$0.isEmpty();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final void clear() {
|
|
this.this$0.clear();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
|
public final Iterator<V> iterator() {
|
|
return new ValueIterator(this.this$0);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final boolean contains(Object obj) {
|
|
return this.this$0.containsValue(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final Object[] toArray() {
|
|
return LocalCache.toArrayList(this).toArray();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final <E> E[] toArray(E[] eArr) {
|
|
return (E[]) LocalCache.toArrayList(this).toArray(eArr);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class EntrySet extends AbstractCacheSet {
|
|
final LocalCache this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
EntrySet(LocalCache localCache) {
|
|
super(localCache);
|
|
this.this$0 = localCache;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public final Iterator<Map.Entry<K, V>> iterator() {
|
|
return new EntryIterator(this.this$0);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public final boolean contains(Object obj) {
|
|
Map.Entry entry;
|
|
Object key;
|
|
V v;
|
|
return (obj instanceof Map.Entry) && (key = (entry = (Map.Entry) obj).getKey()) != null && (v = this.this$0.get(key)) != null && this.this$0.valueEquivalence.equivalent(entry.getValue(), v);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public final boolean remove(Object obj) {
|
|
Map.Entry entry;
|
|
Object key;
|
|
return (obj instanceof Map.Entry) && (key = (entry = (Map.Entry) obj).getKey()) != null && this.this$0.remove(key, entry.getValue());
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static class ManualSerializationProxy<K, V> extends ForwardingCache<K, V> implements Serializable {
|
|
private static final long serialVersionUID = 1;
|
|
final int concurrencyLevel;
|
|
transient Cache<K, V> delegate;
|
|
final long expireAfterAccessNanos;
|
|
final long expireAfterWriteNanos;
|
|
final Equivalence<Object> keyEquivalence;
|
|
final Strength keyStrength;
|
|
final CacheLoader<? super K, V> loader;
|
|
final long maxWeight;
|
|
final RemovalListener<? super K, ? super V> removalListener;
|
|
final Ticker ticker;
|
|
final Equivalence<Object> valueEquivalence;
|
|
final Strength valueStrength;
|
|
final Weigher<K, V> weigher;
|
|
|
|
ManualSerializationProxy(LocalCache<K, V> localCache) {
|
|
this(localCache.keyStrength, localCache.valueStrength, localCache.keyEquivalence, localCache.valueEquivalence, localCache.expireAfterWriteNanos, localCache.expireAfterAccessNanos, localCache.maxWeight, localCache.weigher, localCache.concurrencyLevel, localCache.removalListener, localCache.ticker, localCache.defaultLoader);
|
|
}
|
|
|
|
private ManualSerializationProxy(Strength strength, Strength strength2, Equivalence<Object> equivalence, Equivalence<Object> equivalence2, long j, long j2, long j3, Weigher<K, V> weigher, int i, RemovalListener<? super K, ? super V> removalListener, Ticker ticker, CacheLoader<? super K, V> cacheLoader) {
|
|
this.keyStrength = strength;
|
|
this.valueStrength = strength2;
|
|
this.keyEquivalence = equivalence;
|
|
this.valueEquivalence = equivalence2;
|
|
this.expireAfterWriteNanos = j;
|
|
this.expireAfterAccessNanos = j2;
|
|
this.maxWeight = j3;
|
|
this.weigher = weigher;
|
|
this.concurrencyLevel = i;
|
|
this.removalListener = removalListener;
|
|
this.ticker = (ticker == Ticker.systemTicker() || ticker == CacheBuilder.NULL_TICKER) ? null : ticker;
|
|
this.loader = cacheLoader;
|
|
}
|
|
|
|
CacheBuilder<K, V> recreateCacheBuilder() {
|
|
CacheBuilder<K, V> cacheBuilder = (CacheBuilder<K, V>) CacheBuilder.newBuilder().setKeyStrength(this.keyStrength).setValueStrength(this.valueStrength).keyEquivalence(this.keyEquivalence).valueEquivalence(this.valueEquivalence).concurrencyLevel(this.concurrencyLevel).removalListener(this.removalListener);
|
|
cacheBuilder.strictParsing = false;
|
|
long j = this.expireAfterWriteNanos;
|
|
if (j > 0) {
|
|
cacheBuilder.expireAfterWrite(j, TimeUnit.NANOSECONDS);
|
|
}
|
|
long j2 = this.expireAfterAccessNanos;
|
|
if (j2 > 0) {
|
|
cacheBuilder.expireAfterAccess(j2, TimeUnit.NANOSECONDS);
|
|
}
|
|
if (this.weigher != CacheBuilder.OneWeigher.INSTANCE) {
|
|
cacheBuilder.weigher(this.weigher);
|
|
long j3 = this.maxWeight;
|
|
if (j3 != -1) {
|
|
cacheBuilder.maximumWeight(j3);
|
|
}
|
|
} else {
|
|
long j4 = this.maxWeight;
|
|
if (j4 != -1) {
|
|
cacheBuilder.maximumSize(j4);
|
|
}
|
|
}
|
|
Ticker ticker = this.ticker;
|
|
if (ticker != null) {
|
|
cacheBuilder.ticker(ticker);
|
|
}
|
|
return cacheBuilder;
|
|
}
|
|
|
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
|
objectInputStream.defaultReadObject();
|
|
this.delegate = (Cache<K, V>) recreateCacheBuilder().build();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.cache.ForwardingCache, com.google.common.collect.ForwardingObject
|
|
public Cache<K, V> delegate() {
|
|
return this.delegate;
|
|
}
|
|
|
|
private Object readResolve() {
|
|
return this.delegate;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static final class LoadingSerializationProxy<K, V> extends ManualSerializationProxy<K, V> implements LoadingCache<K, V>, Serializable {
|
|
private static final long serialVersionUID = 1;
|
|
transient LoadingCache<K, V> autoDelegate;
|
|
|
|
LoadingSerializationProxy(LocalCache<K, V> localCache) {
|
|
super(localCache);
|
|
}
|
|
|
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
|
objectInputStream.defaultReadObject();
|
|
this.autoDelegate = (LoadingCache<K, V>) recreateCacheBuilder().build(this.loader);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public final V get(K k) throws ExecutionException {
|
|
return this.autoDelegate.get(k);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public final V getUnchecked(K k) {
|
|
return this.autoDelegate.getUnchecked(k);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public final ImmutableMap<K, V> getAll(Iterable<? extends K> iterable) throws ExecutionException {
|
|
return this.autoDelegate.getAll(iterable);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache, com.google.common.base.Function
|
|
public final V apply(K k) {
|
|
return this.autoDelegate.apply(k);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public final void refresh(K k) {
|
|
this.autoDelegate.refresh(k);
|
|
}
|
|
|
|
private Object readResolve() {
|
|
return this.autoDelegate;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class LocalManualCache<K, V> implements Cache<K, V>, Serializable {
|
|
private static final long serialVersionUID = 1;
|
|
final LocalCache<K, V> localCache;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public LocalManualCache(CacheBuilder<? super K, ? super V> cacheBuilder) {
|
|
this(new LocalCache(cacheBuilder, null));
|
|
}
|
|
|
|
private LocalManualCache(LocalCache<K, V> localCache) {
|
|
this.localCache = localCache;
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public V getIfPresent(Object obj) {
|
|
return this.localCache.getIfPresent(obj);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public V get(K k, Callable<? extends V> callable) throws ExecutionException {
|
|
Preconditions.checkNotNull(callable);
|
|
return this.localCache.get(k, new CacheLoader<Object, V>(this, callable) { // from class: com.google.common.cache.LocalCache.LocalManualCache.1
|
|
final Callable val$valueLoader;
|
|
|
|
{
|
|
this.val$valueLoader = callable;
|
|
}
|
|
|
|
@Override // com.google.common.cache.CacheLoader
|
|
public V load(Object obj) throws Exception {
|
|
return (V) this.val$valueLoader.call();
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public ImmutableMap<K, V> getAllPresent(Iterable<?> iterable) {
|
|
return this.localCache.getAllPresent(iterable);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void put(K k, V v) {
|
|
this.localCache.put(k, v);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void putAll(Map<? extends K, ? extends V> map) {
|
|
this.localCache.putAll(map);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void invalidate(Object obj) {
|
|
Preconditions.checkNotNull(obj);
|
|
this.localCache.remove(obj);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void invalidateAll(Iterable<?> iterable) {
|
|
this.localCache.invalidateAll(iterable);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void invalidateAll() {
|
|
this.localCache.clear();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public long size() {
|
|
return this.localCache.longSize();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public CacheStats stats() {
|
|
AbstractCache.SimpleStatsCounter simpleStatsCounter = new AbstractCache.SimpleStatsCounter();
|
|
simpleStatsCounter.incrementBy(this.localCache.globalStatsCounter);
|
|
for (Segment<K, V> segment : this.localCache.segments) {
|
|
simpleStatsCounter.incrementBy(segment.statsCounter);
|
|
}
|
|
return simpleStatsCounter.snapshot();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void cleanUp() {
|
|
this.localCache.cleanUp();
|
|
}
|
|
|
|
Object writeReplace() {
|
|
return new ManualSerializationProxy(this.localCache);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public ConcurrentMap<K, V> asMap() {
|
|
return this.localCache;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class LocalLoadingCache<K, V> extends LocalManualCache<K, V> implements LoadingCache<K, V> {
|
|
private static final long serialVersionUID = 1;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public LocalLoadingCache(CacheBuilder<? super K, ? super V> cacheBuilder, CacheLoader<? super K, V> cacheLoader) {
|
|
super();
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public V get(K k) throws ExecutionException {
|
|
return this.localCache.getOrLoad(k);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public V getUnchecked(K k) {
|
|
try {
|
|
return get(k);
|
|
} catch (ExecutionException e) {
|
|
throw new UncheckedExecutionException(e.getCause());
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public ImmutableMap<K, V> getAll(Iterable<? extends K> iterable) throws ExecutionException {
|
|
return this.localCache.getAll(iterable);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache
|
|
public void refresh(K k) {
|
|
this.localCache.refresh(k);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LoadingCache, com.google.common.base.Function
|
|
public final V apply(K k) {
|
|
return getUnchecked(k);
|
|
}
|
|
|
|
@Override // com.google.common.cache.LocalCache.LocalManualCache
|
|
Object writeReplace() {
|
|
return new LoadingSerializationProxy(this.localCache);
|
|
}
|
|
}
|
|
|
|
boolean refreshes() {
|
|
return this.refreshNanos > 0;
|
|
}
|
|
|
|
boolean expiresAfterWrite() {
|
|
return this.expireAfterWriteNanos > 0;
|
|
}
|
|
|
|
boolean expiresAfterAccess() {
|
|
return this.expireAfterAccessNanos > 0;
|
|
}
|
|
|
|
boolean evictsBySize() {
|
|
return this.maxWeight >= 0;
|
|
}
|
|
|
|
static <K, V> ValueReference<K, V> unset() {
|
|
return (ValueReference<K, V>) UNSET;
|
|
}
|
|
|
|
static <E> Queue<E> discardingQueue() {
|
|
return (Queue<E>) DISCARDING_QUEUE;
|
|
}
|
|
}
|