Package org.ehcache.sizeof.util
Class WeakIdentityConcurrentMap<K,V>
- java.lang.Object
-
- org.ehcache.sizeof.util.WeakIdentityConcurrentMap<K,V>
-
- Type Parameters:
K- The key typeV- The value type
public final class WeakIdentityConcurrentMap<K,V> extends java.lang.ObjectA poor man's implementation of a WeakIdentityConcurrentMap to hold the CacheManager associated ExecutorServices
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWeakIdentityConcurrentMap.CleanUpTask<T>private static classWeakIdentityConcurrentMap.IdentityWeakReference<T>
-
Field Summary
Fields Modifier and Type Field Description private WeakIdentityConcurrentMap.CleanUpTask<V>cleanUpTaskprivate java.util.concurrent.ConcurrentMap<java.lang.ref.WeakReference<K>,V>mapprivate java.lang.ref.ReferenceQueue<K>queue
-
Constructor Summary
Constructors Constructor Description WeakIdentityConcurrentMap()ConstructorWeakIdentityConcurrentMap(WeakIdentityConcurrentMap.CleanUpTask<V> cleanUpTask)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()booleancontainsKey(K key)Vget(K key)java.util.Set<K>keySet()Vput(K key, V value)Puts into the underlyingVputIfAbsent(K key, V value)Puts into the underlyingVremove(K key)Remove from the underlyingjava.lang.StringtoString()
-
-
-
Field Detail
-
queue
private final java.lang.ref.ReferenceQueue<K> queue
-
cleanUpTask
private final WeakIdentityConcurrentMap.CleanUpTask<V> cleanUpTask
-
-
Constructor Detail
-
WeakIdentityConcurrentMap
public WeakIdentityConcurrentMap()
Constructor
-
WeakIdentityConcurrentMap
public WeakIdentityConcurrentMap(WeakIdentityConcurrentMap.CleanUpTask<V> cleanUpTask)
Constructor- Parameters:
cleanUpTask- task cleaning up references
-
-
Method Detail
-
put
public V put(K key, V value)
Puts into the underlying- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
-
remove
public V remove(K key)
Remove from the underlying- Parameters:
key- key whose mapping is to be removed from the map- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
putIfAbsent
public V putIfAbsent(K key, V value)
Puts into the underlying- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with the specified key, or
nullif there was no mapping for the key. (Anullreturn can also indicate that the map previously associatednullwith the key, if the implementation supports null values.)
-
get
public V get(K key)
- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
nullif this map contains no mapping for the key
-
cleanUp
public void cleanUp()
-
keySet
public java.util.Set<K> keySet()
- Returns:
- a set view of the keys contained in this map
-
containsKey
public boolean containsKey(K key)
-
-