MCPcopy Create free account
hub / github.com/antlr/codebuff / remove

Method remove

output/java_guava/1.4.17/LocalCache.java:3149–3188  ·  view source on GitHub ↗
(Object key, int hash)

Source from the content-addressed store, hash-verified

3147 }
3148
3149 @Nullable
3150 V remove(Object key, int hash) {
3151 lock();
3152 try {
3153 long now = map.ticker.read();
3154 preWriteCleanup(now);
3155 int newCount = this.count - 1;
3156 AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table;
3157 int index = hash & (table.length() - 1);
3158 ReferenceEntry<K, V> first = table.get(index);
3159 for (ReferenceEntry<K, V> e = first; e != null; e = e.getNext()) {
3160 K entryKey = e.getKey();
3161 if (e.getHash() == hash && entryKey != null
3162 && map.keyEquivalence.equivalent(key, entryKey)) {
3163 ValueReference<K, V> valueReference = e.getValueReference();
3164 V entryValue = valueReference.get();
3165 RemovalCause cause;
3166 if (entryValue != null) {
3167 cause = RemovalCause.EXPLICIT;
3168 } else if (valueReference.isActive()) {
3169 cause = RemovalCause.COLLECTED;
3170 } else {
3171 // currently loading
3172 return null;
3173 }
3174
3175 ++modCount;
3176 ReferenceEntry<K, V> newFirst = removeValueFromChain(first, e, entryKey, hash, entryValue, valueReference, cause);
3177 newCount = this.count - 1;
3178 table.set(index, newFirst);
3179 this.count = newCount; // write-volatile
3180 return entryValue;
3181 }
3182 }
3183 return null;
3184 } finally {
3185 unlock();
3186 postWriteCleanup();
3187 }
3188 }
3189
3190 boolean storeLoadedValue(K key, int hash, LoadingValueReference<K, V> oldValueReference, V newValue) {
3191 lock();

Callers

nothing calls this directly

Calls 15

preWriteCleanupMethod · 0.95
removeValueFromChainMethod · 0.95
postWriteCleanupMethod · 0.95
getMethod · 0.65
getNextMethod · 0.65
getKeyMethod · 0.65
getHashMethod · 0.65
getValueReferenceMethod · 0.65
isActiveMethod · 0.65
setMethod · 0.65
lockMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected