/** * Copies {@code original} into a new entry chained to {@code newNext}. Returns the new entry, * or {@code null} if {@code original} was already garbage collected. */ @GuardedBy("Segment.this") ReferenceEntry<K, V> copyEntry(ReferenceEntry<K, V> original, ReferenceEntry<K, V> newNext) { if (original.getKey() == null) { // key collected return null; } ValueReference<K, V> valueReference = original.getValueReference(); V value = valueReference.get(); if ((value == null) && !valueReference.isComputingReference()) { // value collected return null; } ReferenceEntry<K, V> newEntry = map.entryFactory.copyEntry(this, original, newNext); newEntry.setValueReference(valueReference.copyFor(this.valueReferenceQueue, value, newEntry)); return newEntry; }
/** * Waits for a computation to complete. Returns the result of the computation. */ @Override public V waitForValue() throws ExecutionException { if (computedReference == UNSET) { boolean interrupted = false; try { synchronized (this) { while (computedReference == UNSET) { try { wait(); } catch (InterruptedException ie) { interrupted = true; } } } } finally { if (interrupted) { Thread.currentThread().interrupt(); } } } return computedReference.waitForValue(); }
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
if (e == null || !e.getValueReference().isComputingReference()) { boolean createNewEntry = true; ComputingValueReference<K, V> computingValueReference = null; && map.keyEquivalence.equivalent(key, entryKey)) { ValueReference<K, V> valueReference = e.getValueReference(); if (valueReference.isComputingReference()) { createNewEntry = false; } else { V value = e.getValueReference().get(); if (value == null) { enqueueNotification(entryKey, hash, value, RemovalCause.COLLECTED); V value = e.getValueReference().waitForValue(); if (value != null) { recordRead(e);
V entryValue = valueReference.get(); if (!valueReference.isComputingReference()) { enqueueNotification(key, hash, entryValue, RemovalCause.COLLECTED); newCount = this.count; // count remains unchanged
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }
void clear() { if (count != 0) { lock(); try { AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table; if (map.removalNotificationQueue != DISCARDING_QUEUE) { for (int i = 0; i < table.length(); ++i) { for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) { // Computing references aren't actually in the map yet. if (!e.getValueReference().isComputingReference()) { enqueueNotification(e, RemovalCause.EXPLICIT); } } } } for (int i = 0; i < table.length(); ++i) { table.set(i, null); } clearReferenceQueues(); evictionQueue.clear(); expirationQueue.clear(); readCount.set(0); ++modCount; count = 0; // write-volatile } finally { unlock(); postWriteCleanup(); } } }