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>(); count = 0; // write-volatile } finally { unlock(); } } } }
boolean replace(K key, int hash, V oldValue, V newValue) { lock(); try { 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; } finally { unlock(); } }
segments[i].unlock();
segments[i].unlock();
V replace(K key, int hash, V newValue) { lock(); try { 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; } 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>(); count = 0; // write-volatile } 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(); } }
boolean replace(K key, int hash, V oldValue, V newValue) { lock(); try { 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; } finally { unlock(); } }
segments[i].unlock();
segments[i].unlock();
V replace(K key, int hash, V newValue) { lock(); try { 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; } 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(); } }