eviction.onEntryRemove( e ); eviction.onEntryRemove( p ); newFirst = eviction.createNewEntry( p.key, p.hash, newFirst, p.value ); eviction.onEntryMiss( newFirst );
try { int c = count; if ( c++ > threshold && eviction.strategy() == Eviction.NONE ) { rehash(); if ( !onlyIfAbsent ) { e.value = value; eviction.onEntryHit( e ); ++modCount; if ( eviction.strategy() != Eviction.NONE ) { if ( c > evictCap ) { evicted = eviction.execute(); tab[index] = eviction.createNewEntry( key, hash, first, value ); Set<HashEntry<K, V>> newlyEvicted = eviction.onEntryMiss( tab[index] ); if ( !newlyEvicted.isEmpty() ) { if ( evicted != null ) { tab[index] = eviction.createNewEntry( key, hash, first, value );
int k = p.hash & sizeMask; HashEntry<K, V> n = newTable[k]; newTable[k] = eviction.createNewEntry( p.key, p.hash, n, p.value );
try { int c = count; if ( c++ > threshold && eviction.strategy() == Eviction.NONE ) { rehash(); if ( !onlyIfAbsent ) { e.value = value; eviction.onEntryHit( e ); ++modCount; if ( eviction.strategy() != Eviction.NONE ) { if ( c > evictCap ) { evicted = eviction.execute(); tab[index] = eviction.createNewEntry( key, hash, first, value ); Set<HashEntry<K, V>> newlyEvicted = eviction.onEntryMiss( tab[index] ); if ( !newlyEvicted.isEmpty() ) { if ( evicted != null ) { tab[index] = eviction.createNewEntry( key, hash, first, value );
eviction.onEntryRemove( e ); eviction.onEntryRemove( p ); newFirst = eviction.createNewEntry( p.key, p.hash, newFirst, p.value ); eviction.onEntryMiss( newFirst );
V get(Object key, int hash) { int c = count; if ( c != 0 ) { // read-volatile V result = null; HashEntry<K, V> e = getFirst( hash ); while ( e != null ) { if ( e.hash == hash && key.equals( e.key ) ) { V v = e.value; if ( v != null ) { result = v; break; } else { result = readValueUnderLock( e ); // recheck break; } } e = e.next; } // a hit if ( result != null ) { if ( eviction.onEntryHit( e ) ) { Set<HashEntry<K, V>> evicted = attemptEviction( false ); notifyEvictionListener( evicted ); } } return result; } return null; }
V replace(K key, int hash, V newValue) { lock(); Set<HashEntry<K, V>> evicted = null; try { HashEntry<K, V> e = getFirst( hash ); while ( e != null && ( e.hash != hash || !key.equals( e.key ) ) ) { e = e.next; } V oldValue = null; if ( e != null ) { oldValue = e.value; e.value = newValue; if ( eviction.onEntryHit( e ) ) { evicted = attemptEviction( true ); } } return oldValue; } finally { unlock(); notifyEvictionListener( evicted ); } }
boolean replace(K key, int hash, V oldValue, V newValue) { lock(); Set<HashEntry<K, V>> evicted = null; try { HashEntry<K, V> e = getFirst( hash ); while ( e != null && ( e.hash != hash || !key.equals( e.key ) ) ) { e = e.next; } boolean replaced = false; if ( e != null && oldValue.equals( e.value ) ) { replaced = true; e.value = newValue; if ( eviction.onEntryHit( e ) ) { evicted = attemptEviction( true ); } } return replaced; } finally { unlock(); notifyEvictionListener( evicted ); } }
private Set<HashEntry<K, V>> attemptEviction(boolean lockedAlready) { Set<HashEntry<K, V>> evicted = null; boolean obtainedLock = lockedAlready || tryLock(); if ( !obtainedLock && eviction.thresholdExpired() ) { lock(); obtainedLock = true; } if ( obtainedLock ) { try { if ( eviction.thresholdExpired() ) { evicted = eviction.execute(); } } finally { if ( !lockedAlready ) { unlock(); } } } return evicted; }
void clear() { if ( count != 0 ) { lock(); try { HashEntry<K, V>[] tab = table; for ( int i = 0; i < tab.length; i++ ) { tab[i] = null; } ++modCount; eviction.clear(); count = 0; // write-volatile } finally { unlock(); } } }
int k = p.hash & sizeMask; HashEntry<K, V> n = newTable[k]; newTable[k] = eviction.createNewEntry( p.key, p.hash, n, p.value );
V get(Object key, int hash) { int c = count; if ( c != 0 ) { // read-volatile V result = null; HashEntry<K, V> e = getFirst( hash ); while ( e != null ) { if ( e.hash == hash && key.equals( e.key ) ) { V v = e.value; if ( v != null ) { result = v; break; } else { result = readValueUnderLock( e ); // recheck break; } } e = e.next; } // a hit if ( result != null ) { if ( eviction.onEntryHit( e ) ) { Set<HashEntry<K, V>> evicted = attemptEviction( false ); notifyEvictionListener( evicted ); } } return result; } return null; }
boolean replace(K key, int hash, V oldValue, V newValue) { lock(); Set<HashEntry<K, V>> evicted = null; try { HashEntry<K, V> e = getFirst( hash ); while ( e != null && ( e.hash != hash || !key.equals( e.key ) ) ) { e = e.next; } boolean replaced = false; if ( e != null && oldValue.equals( e.value ) ) { replaced = true; e.value = newValue; if ( eviction.onEntryHit( e ) ) { evicted = attemptEviction( true ); } } return replaced; } finally { unlock(); notifyEvictionListener( evicted ); } }
V replace(K key, int hash, V newValue) { lock(); Set<HashEntry<K, V>> evicted = null; try { HashEntry<K, V> e = getFirst( hash ); while ( e != null && ( e.hash != hash || !key.equals( e.key ) ) ) { e = e.next; } V oldValue = null; if ( e != null ) { oldValue = e.value; e.value = newValue; if ( eviction.onEntryHit( e ) ) { evicted = attemptEviction( true ); } } return oldValue; } finally { unlock(); notifyEvictionListener( evicted ); } }
private Set<HashEntry<K, V>> attemptEviction(boolean lockedAlready) { Set<HashEntry<K, V>> evicted = null; boolean obtainedLock = lockedAlready || tryLock(); if ( !obtainedLock && eviction.thresholdExpired() ) { lock(); obtainedLock = true; } if ( obtainedLock ) { try { if ( eviction.thresholdExpired() ) { evicted = eviction.execute(); } } finally { if ( !lockedAlready ) { unlock(); } } } return evicted; }
void clear() { if ( count != 0 ) { lock(); try { HashEntry<K, V>[] tab = table; for ( int i = 0; i < tab.length; i++ ) { tab[i] = null; } ++modCount; eviction.clear(); count = 0; // write-volatile } finally { unlock(); } } }