(Object key, int hash)
| 3121 | } |
| 3122 | |
| 3123 | @Nullable |
| 3124 | V remove(Object key, int hash) { |
| 3125 | lock(); |
| 3126 | try { |
| 3127 | long now = map.ticker.read(); |
| 3128 | preWriteCleanup(now); |
| 3129 | |
| 3130 | int newCount = this.count - 1; |
| 3131 | AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; |
| 3132 | int index = hash & (table.length() - 1); |
| 3133 | ReferenceEntry<K, V> first = table.get(index); |
| 3134 | |
| 3135 | for (ReferenceEntry<K, V> e = first; e != null; e = e.getNext()) { |
| 3136 | K entryKey = e.getKey(); |
| 3137 | if (e.getHash() == hash |
| 3138 | && entryKey != null |
| 3139 | && map.keyEquivalence.equivalent(key, entryKey)) { |
| 3140 | ValueReference<K, V> valueReference = e.getValueReference(); |
| 3141 | V entryValue = valueReference.get(); |
| 3142 | |
| 3143 | RemovalCause cause; |
| 3144 | if (entryValue != null) { |
| 3145 | cause = RemovalCause.EXPLICIT; |
| 3146 | } else if (valueReference.isActive()) { |
| 3147 | cause = RemovalCause.COLLECTED; |
| 3148 | } else { |
| 3149 | // currently loading |
| 3150 | return null; |
| 3151 | } |
| 3152 | |
| 3153 | ++modCount; |
| 3154 | ReferenceEntry<K, V> newFirst = |
| 3155 | removeValueFromChain(first, e, entryKey, hash, entryValue, valueReference, cause); |
| 3156 | newCount = this.count - 1; |
| 3157 | table.set(index, newFirst); |
| 3158 | this.count = newCount; // write-volatile |
| 3159 | return entryValue; |
| 3160 | } |
| 3161 | } |
| 3162 | |
| 3163 | return null; |
| 3164 | } finally { |
| 3165 | unlock(); |
| 3166 | postWriteCleanup(); |
| 3167 | } |
| 3168 | } |
| 3169 | |
| 3170 | boolean storeLoadedValue( |
| 3171 | K key, int hash, LoadingValueReference<K, V> oldValueReference, V newValue) { |
nothing calls this directly
no test coverage detected