@Override public boolean contains(Object o) { return (o instanceof AccessOrder<?>) && contains((AccessOrder<?>) o); }
boolean remove(E e) { if (contains(e)) { unlink(e); return true; } return false; }
@Override public boolean contains(Object o) { return (o instanceof AccessOrder<?>) && contains((AccessOrder<?>) o); }
boolean remove(E e) { if (contains(e)) { unlink(e); return true; } return false; }
/** Promote the node from probation to protected on an access. */ @GuardedBy("evictionLock") void reorderProbation(Node<K, V> node) { if (!accessOrderProbationDeque().contains(node)) { // Ignore stale accesses for an entry that is no longer present return; } else if (node.getPolicyWeight() > mainProtectedMaximum()) { return; } long mainProtectedWeightedSize = mainProtectedWeightedSize() + node.getPolicyWeight(); accessOrderProbationDeque().remove(node); accessOrderProtectedDeque().add(node); node.makeMainProtected(); long mainProtectedMaximum = mainProtectedMaximum(); while (mainProtectedWeightedSize > mainProtectedMaximum) { Node<K, V> demoted = accessOrderProtectedDeque().pollFirst(); if (demoted == null) { break; } demoted.makeMainProbation(); accessOrderProbationDeque().add(demoted); mainProtectedWeightedSize -= demoted.getPolicyWeight(); } lazySetMainProtectedWeightedSize(mainProtectedWeightedSize); }
/** Promote the node from probation to protected on an access. */ @GuardedBy("evictionLock") void reorderProbation(Node<K, V> node) { if (!accessOrderProbationDeque().contains(node)) { // Ignore stale accesses for an entry that is no longer present return; } else if (node.getPolicyWeight() > mainProtectedMaximum()) { return; } long mainProtectedWeightedSize = mainProtectedWeightedSize() + node.getPolicyWeight(); accessOrderProbationDeque().remove(node); accessOrderProtectedDeque().add(node); node.makeMainProtected(); long mainProtectedMaximum = mainProtectedMaximum(); while (mainProtectedWeightedSize > mainProtectedMaximum) { Node<K, V> demoted = accessOrderProtectedDeque().pollFirst(); if (demoted == null) { break; } demoted.makeMainProbation(); accessOrderProbationDeque().add(demoted); mainProtectedWeightedSize -= demoted.getPolicyWeight(); } lazySetMainProtectedWeightedSize(mainProtectedWeightedSize); }