private boolean replaceInternal2(K key, int hash, V oldValue, V newValue) { removeStale(); HashEntry<K, V> e = getFirst(hash); while (e != null && (e.hash != hash || !keyEq(key, e.key()))) { e = e.next; } boolean replaced = false; if (e != null && oldValue.equals(e.value())) { replaced = true; e.setValue(newValue, valueType, refQueue); } return replaced; }
private boolean replaceInternal2(K key, int hash, V oldValue, V newValue) { removeStale(); HashEntry<K, V> e = getFirst(hash); while (e != null && (e.hash != hash || !keyEq(key, e.key()))) { e = e.next; } boolean replaced = false; if (e != null && oldValue.equals(e.value())) { replaced = true; e.setValue(newValue, valueType, refQueue); } return replaced; }
private V removeInternal(Object key, int hash, Object value, boolean refRemove) { if (!refRemove) { removeStale();
private V removeInternal(Object key, int hash, Object value, boolean refRemove) { if (!refRemove) { removeStale();
private V putInternal(K key, int hash, V value, IFunction<? super K, ? extends V> function, boolean onlyIfAbsent) { removeStale(); int c = count;
private V putInternal(K key, int hash, V value, IFunction<? super K, ? extends V> function, boolean onlyIfAbsent) { removeStale(); int c = count;
/** * Reads value field of an entry under lock. Called if value * field ever appears to be null. This is possible only if a * compiler happens to reorder a HashEntry initialization with * its table assignment, which is legal under memory model * but is not known to ever occur. */ V readValueUnderLock(HashEntry<K, V> e) { lock(); try { removeStale(); return e.value(); } finally { unlock(); } }
/** * Reads value field of an entry under lock. Called if value * field ever appears to be null. This is possible only if a * compiler happens to reorder a HashEntry initialization with * its table assignment, which is legal under memory model * but is not known to ever occur. */ V readValueUnderLock(HashEntry<K, V> e) { lock(); try { removeStale(); return e.value(); } finally { unlock(); } }
/** * Removes any stale entries whose keys have been finalized. Use of this * method is normally not necessary since stale entries are automatically * removed lazily, when blocking operations are required. However, there * are some cases where this operation should be performed eagerly, such * as cleaning up old references to a ClassLoader in a multi-classloader * environment. * <p> * Note: this method will acquire locks one at a time across all segments * of this table, so this method should be used sparingly. */ public void purgeStaleEntries() { for (int i = 0; i < segments.length; ++i) { segments[i].removeStale(); } }
/** * Removes any stale entries whose keys have been finalized. Use of this * method is normally not necessary since stale entries are automatically * removed lazily, when blocking operations are required. However, there * are some cases where this operation should be performed eagerly, such * as cleaning up old references to a ClassLoader in a multi-classloader * environment. * <p> * Note: this method will acquire locks one at a time across all segments * of this table, so this method should be used sparingly. */ public void purgeStaleEntries() { for (int i = 0; i < segments.length; ++i) { segments[i].removeStale(); } }
private V replaceInternal(K key, int hash, V newValue) { removeStale(); HashEntry<K, V> e = getFirst(hash); while (e != null && (e.hash != hash || !keyEq(key, e.key()))) { e = e.next; } V oldValue = null; if (e != null) { oldValue = e.value(); e.setValue(newValue, valueType, refQueue); } return oldValue; }
private V replaceInternal(K key, int hash, V newValue) { removeStale(); HashEntry<K, V> e = getFirst(hash); while (e != null && (e.hash != hash || !keyEq(key, e.key()))) { e = e.next; } V oldValue = null; if (e != null) { oldValue = e.value(); e.setValue(newValue, valueType, refQueue); } return oldValue; }