/** * Removes the entry from being scheduled to be evicted. * <p/> * Cleans up parent container (second -> entries map) if it doesn't hold anymore items this second. * <p/> * Cancels associated scheduler (second -> scheduler map ) if there are no more items to remove for this second. * <p/> * Returns associated scheduled entry. * * @param second second at which this entry was scheduled to be evicted * @param entries entries which were already scheduled to be evicted for this second * @param key entry key * @return associated scheduled entry */ private ScheduledEntry<K, V> cancelAndCleanUpIfEmpty(Integer second, Map<Object, ScheduledEntry<K, V>> entries, Object key) { ScheduledEntry<K, V> result = entries.remove(key); cleanUpScheduledFuturesIfEmpty(second, entries); return result; }
/** * Removes the entry from being scheduled to be evicted. * <p/> * Cleans up parent container (second -> entries map) if it doesn't hold anymore items this second. * <p/> * Cancels associated scheduler (second -> scheduler map ) if there are no more items to remove for this second. * <p/> * Returns associated scheduled entry. * * @param second second at which this entry was scheduled to be evicted * @param entries entries which were already scheduled to be evicted for this second * @param key entry key * @return associated scheduled entry */ private ScheduledEntry<K, V> cancelAndCleanUpIfEmpty(Integer second, Map<Object, ScheduledEntry<K, V>> entries, Object key) { ScheduledEntry<K, V> result = entries.remove(key); cleanUpScheduledFuturesIfEmpty(second, entries); return result; }
/** * Removes the entry if it exists from being scheduled to be evicted. * <p/> * Cleans up parent container (second -> entries map) if it doesn't hold anymore items this second. * <p/> * Cancels associated scheduler (second -> scheduler map ) if there are no more items to remove for this second. * <p/> * Returns associated scheduled entry. * * @param second second at which this entry was scheduled to be evicted * @param entries entries which were already scheduled to be evicted for this second * @param key entry key * @param entryToRemove entry value that is expected to exist in the map * @return true if entryToRemove exists in the map and removed */ private boolean cancelAndCleanUpIfEmpty(Integer second, Map<Object, ScheduledEntry<K, V>> entries, Object key, ScheduledEntry<K, V> entryToRemove) { ScheduledEntry<K, V> entry = entries.get(key); if (entry == null || !entry.equals(entryToRemove)) { return false; } entries.remove(key); cleanUpScheduledFuturesIfEmpty(second, entries); return true; }
/** * Removes the entry if it exists from being scheduled to be evicted. * <p/> * Cleans up parent container (second -> entries map) if it doesn't hold anymore items this second. * <p/> * Cancels associated scheduler (second -> scheduler map ) if there are no more items to remove for this second. * <p/> * Returns associated scheduled entry. * * @param second second at which this entry was scheduled to be evicted * @param entries entries which were already scheduled to be evicted for this second * @param key entry key * @param entryToRemove entry value that is expected to exist in the map * @return true if entryToRemove exists in the map and removed */ private boolean cancelAndCleanUpIfEmpty(Integer second, Map<Object, ScheduledEntry<K, V>> entries, Object key, ScheduledEntry<K, V> entryToRemove) { ScheduledEntry<K, V> entry = entries.get(key); if (entry == null || !entry.equals(entryToRemove)) { return false; } entries.remove(key); cleanUpScheduledFuturesIfEmpty(second, entries); return true; }