void removeCollectedEntry(@Nonnull ReferenceEntry<K, V> entry) { enqueueNotification(entry, RemovalCause.COLLECTED); writeQueue.remove(entry); accessQueue.remove(entry); }
@Nullable ReferenceEntry<K, V> removeValueFromChain(ReferenceEntry<K, V> first, @Nonnull ReferenceEntry<K, V> entry, K key, int hash, @Nonnull ValueReference<K, V> valueReference, RemovalCause cause) { enqueueNotification(key, hash, valueReference, cause); writeQueue.remove(entry); accessQueue.remove(entry); if (valueReference.isLoading()) { valueReference.notifyNewValue(null); return first; } else { return removeEntryFromChain(first, entry); } }
void clear() { if (count != 0) { // read-volatile lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Loading references aren't actually in the map yet. if (e.getValueReference().isActive()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); writeQueue.clear(); accessQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
++modCount; if (valueReference.isActive()) { enqueueNotification(key, hash, valueReference, RemovalCause.COLLECTED); setValue(e, key, value, now); newCount = this.count; // count remains unchanged enqueueNotification(key, hash, valueReference, RemovalCause.REPLACED); setValue(e, key, value, now); evictEntries(e);
V value = valueReference.get(); if (value == null) { enqueueNotification(entryKey, hash, valueReference, RemovalCause.COLLECTED); } else if (map.isExpired(e, now)) { enqueueNotification(entryKey, hash, valueReference, RemovalCause.EXPIRED); } else { recordLockedRead(e, now);
RemovalCause cause = (entryValue == null) ? RemovalCause.COLLECTED : RemovalCause.REPLACED; enqueueNotification(key, hash, oldValueReference, cause); newCount--; enqueueNotification(key, hash, valueReference, RemovalCause.REPLACED); return false;
enqueueNotification(key, hash, valueReference, RemovalCause.REPLACED); setValue(e, key, newValue, now); evictEntries(e);
enqueueNotification(key, hash, valueReference, RemovalCause.REPLACED); setValue(e, key, newValue, now); evictEntries(e);
void enqueueNotification(@Nonnull ReferenceEntry<K, V> entry, RemovalCause cause) { enqueueNotification(entry.getKey(), entry.getHash(), entry.getValueReference(), cause); }