(Object key, int hash)
| 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(); |
nothing calls this directly
no test coverage detected