@Override public void clear() { writeLock.lock(); try { for (ExpiringEntry<K, V> entry : entries.values()) entry.cancel(); entries.clear(); } finally { writeLock.unlock(); } }
@Override public void clear() { writeLock.lock(); try { for (ExpiringEntry<K, V> entry : entries.values()) entry.cancel(); entries.clear(); } finally { writeLock.unlock(); } }
@Override public void clear() { writeLock.lock(); try { for (ExpiringEntry<K, V> entry : entries.values()) entry.cancel(); entries.clear(); } finally { writeLock.unlock(); } }
/** * Resets the given entry's schedule canceling any existing scheduled expiration and reordering the entry in the * internal map. Schedules the next entry in the map if the given {@code entry} was scheduled or if * {@code scheduleNext} is true. * * @param entry to reset * @param scheduleFirstEntry whether the first entry should be automatically scheduled */ void resetEntry(ExpiringEntry<K, V> entry, boolean scheduleFirstEntry) { writeLock.lock(); try { boolean scheduled = entry.cancel(); entries.reorder(entry); if (scheduled || scheduleFirstEntry) scheduleEntry(entries.first()); } finally { writeLock.unlock(); } }
/** * Resets the given entry's schedule canceling any existing scheduled expiration and reordering the entry in the * internal map. Schedules the next entry in the map if the given {@code entry} was scheduled or if * {@code scheduleNext} is true. * * @param entry to reset * @param scheduleFirstEntry whether the first entry should be automatically scheduled */ void resetEntry(ExpiringEntry<K, V> entry, boolean scheduleFirstEntry) { writeLock.lock(); try { boolean scheduled = entry.cancel(); entries.reorder(entry); if (scheduled || scheduleFirstEntry) scheduleEntry(entries.first()); } finally { writeLock.unlock(); } }
/** * Resets the given entry's schedule canceling any existing scheduled expiration and reordering the entry in the * internal map. Schedules the next entry in the map if the given {@code entry} was scheduled or if * {@code scheduleNext} is true. * * @param entry to reset * @param scheduleFirstEntry whether the first entry should be automatically scheduled */ void resetEntry(ExpiringEntry<K, V> entry, boolean scheduleFirstEntry) { writeLock.lock(); try { boolean scheduled = entry.cancel(); entries.reorder(entry); if (scheduled || scheduleFirstEntry) scheduleEntry(entries.first()); } finally { writeLock.unlock(); } }
@Override public boolean remove(Object key, Object value) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null && entry.getValue().equals(value)) { entries.remove(key); if (entry.cancel()) scheduleEntry(entries.first()); return true; } else return false; } finally { writeLock.unlock(); } }
@Override public boolean remove(Object key, Object value) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null && entry.getValue().equals(value)) { entries.remove(key); if (entry.cancel()) scheduleEntry(entries.first()); return true; } else return false; } finally { writeLock.unlock(); } }
@Override public boolean remove(Object key, Object value) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null && entry.getValue().equals(value)) { entries.remove(key); if (entry.cancel()) scheduleEntry(entries.first()); return true; } else return false; } finally { writeLock.unlock(); } }
@Override public V remove(Object key) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.remove(key); if (entry == null) return null; if (entry.cancel()) scheduleEntry(entries.first()); return entry.getValue(); } finally { writeLock.unlock(); } }
@Override public V remove(Object key) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.remove(key); if (entry == null) return null; if (entry.cancel()) scheduleEntry(entries.first()); return entry.getValue(); } finally { writeLock.unlock(); } }
@Override public V remove(Object key) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.remove(key); if (entry == null) return null; if (entry.cancel()) scheduleEntry(entries.first()); return entry.getValue(); } finally { writeLock.unlock(); } }