seg.lock(); try { HashEntry<K, V>[] tab = seg.table;
seg.lock(); try { HashEntry<K, V>[] tab = seg.table;
void clear() { if (count != 0) { lock(); try { HashEntry<K, V>[] tab = table; for (int i = 0; i < tab.length; i++) { tab[i] = null; } ++modCount; // replace the reference queue to avoid unnecessary stale cleanups refQueue = new ReferenceQueue<Object>(); // write-volatile count = 0; } finally { unlock(); } } } }
segments[i].lock();
segments[i].lock();
V applyIfPresent(K key, int hash, IBiFunction<? super K, ? super V, ? extends V> remappingFunction) { lock(); try { V oldValue = get(key, hash); if (oldValue == null) { return null; } V newValue = remappingFunction.apply(key, oldValue); if (newValue == null) { removeInternal(key, hash, oldValue, false); return null; } else { putInternal(key, hash, newValue, null, false); return newValue; } } finally { unlock(); } }
void clear() { if (count != 0) { lock(); try { HashEntry<K, V>[] tab = table; for (int i = 0; i < tab.length; i++) { tab[i] = null; } ++modCount; // replace the reference queue to avoid unnecessary stale cleanups refQueue = new ReferenceQueue<Object>(); // write-volatile count = 0; } finally { unlock(); } } } }
V applyIfPresent(K key, int hash, IBiFunction<? super K, ? super V, ? extends V> remappingFunction) { lock(); try { V oldValue = get(key, hash); if (oldValue == null) { return null; } V newValue = remappingFunction.apply(key, oldValue); if (newValue == null) { removeInternal(key, hash, oldValue, false); return null; } else { putInternal(key, hash, newValue, null, false); return newValue; } } finally { unlock(); } }
V merge(K key, V value, int hash, IBiFunction<? super V, ? super V, ? extends V> remappingFunction) { lock(); try { V oldValue = get(key, hash); V newValue = (oldValue == null) ? value : remappingFunction.apply(oldValue, value); if (newValue == null) { removeInternal(key, hash, oldValue, false); return null; } else { putInternal(key, hash, newValue, null, false); return newValue; } } finally { unlock(); } }
V merge(K key, V value, int hash, IBiFunction<? super V, ? super V, ? extends V> remappingFunction) { lock(); try { V oldValue = get(key, hash); V newValue = (oldValue == null) ? value : remappingFunction.apply(oldValue, value); if (newValue == null) { removeInternal(key, hash, oldValue, false); return null; } else { putInternal(key, hash, newValue, null, false); return newValue; } } 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(); } }
/** * 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(); } }
/** * Remove: match on key only if value is null, else match both. */ V remove(Object key, int hash, Object value, boolean refRemove) { lock(); try { return removeInternal(key, hash, value, refRemove); } finally { unlock(); } }
boolean replace(K key, int hash, V oldValue, V newValue) { lock(); try { return replaceInternal2(key, hash, oldValue, newValue); } finally { unlock(); } }
/** * This method must be called with exactly one of <code>value</code> and * <code>function</code> non-null. **/ V put(K key, int hash, V value, IFunction<? super K, ? extends V> function, boolean onlyIfAbsent) { lock(); try { return putInternal(key, hash, value, function, onlyIfAbsent); } finally { unlock(); } }
V replace(K key, int hash, V newValue) { lock(); try { return replaceInternal(key, hash, newValue); } finally { unlock(); } }
/** * Remove: match on key only if value is null, else match both. */ V remove(Object key, int hash, Object value, boolean refRemove) { lock(); try { return removeInternal(key, hash, value, refRemove); } finally { unlock(); } }
/** * This method must be called with exactly one of <code>value</code> and * <code>function</code> non-null. **/ V put(K key, int hash, V value, IFunction<? super K, ? extends V> function, boolean onlyIfAbsent) { lock(); try { return putInternal(key, hash, value, function, onlyIfAbsent); } finally { unlock(); } }
V replace(K key, int hash, V newValue) { lock(); try { return replaceInternal(key, hash, newValue); } finally { unlock(); } }
boolean replace(K key, int hash, V oldValue, V newValue) { lock(); try { return replaceInternal2(key, hash, oldValue, newValue); } finally { unlock(); } }