Package io.aether.utils
Class WeakConcurrentHashMap<K,V>
- java.lang.Object
-
- io.aether.utils.WeakConcurrentHashMap<K,V>
-
- Type Parameters:
K- the type of keys maintained by this mapV- the type of mapped values
- All Implemented Interfaces:
java.util.concurrent.ConcurrentMap<K,V>,java.util.Map<K,V>
public class WeakConcurrentHashMap<K,V> extends java.lang.Object implements java.util.concurrent.ConcurrentMap<K,V>A thread-safe, concurrent Map implementation with weak keys.This implementation is designed for high-concurrency environments: it relies on lock-free data structures (ConcurrentHashMap) and a single global scheduled task for cleanup, avoiding synchronized blocks and explicit locks on all critical paths.
-
-
Constructor Summary
Constructors Constructor Description WeakConcurrentHashMap()Creates a new WeakConcurrentHashMap and registers it for global cleanup.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)@NotNull java.util.Set<java.util.Map.Entry<K,V>>entrySet()Vget(java.lang.Object key)booleanisEmpty()@NotNull java.util.Set<K>keySet()Vput(K key, V value)voidputAll(@NotNull java.util.Map<? extends K,? extends V> m)VputIfAbsent(K key, V value)booleanremove(@NotNull java.lang.Object key, java.lang.Object value)Vremove(java.lang.Object key)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)static voidshutdownGlobalCleaner()Shuts down the global scheduled cleaner task.intsize()@NotNull java.util.Collection<V>values()The returned collection contains strong references to the values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
remove
public boolean remove(@NotNull @NotNull java.lang.Object key, java.lang.Object value)
-
keySet
@NotNull public @NotNull java.util.Set<K> keySet()
The set is backed by the map. The iterator filters out keys that have been garbage collected ("dead" entries).
-
values
@NotNull public @NotNull java.util.Collection<V> values()
The returned collection contains strong references to the values.
-
entrySet
@NotNull public @NotNull java.util.Set<java.util.Map.Entry<K,V>> entrySet()
The set is backed by the map. The iterator filters out entries whose keys have been garbage collected.
-
shutdownGlobalCleaner
public static void shutdownGlobalCleaner()
Shuts down the global scheduled cleaner task. This method should be called only once when the application exits.
-
-