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.Object
A poor man's implementation of a WeakIdentityConcurrentMap to hold the CacheManager associated ExecutorServices
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
WeakIdentityConcurrentMap.CleanUpTask<T>
private static class
WeakIdentityConcurrentMap.IdentityWeakReference<T>
-
Field Summary
Fields Modifier and Type Field Description private WeakIdentityConcurrentMap.CleanUpTask<V>
cleanUpTask
private java.util.concurrent.ConcurrentMap<java.lang.ref.WeakReference<K>,V>
map
private 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 void
cleanUp()
boolean
containsKey(K key)
V
get(K key)
java.util.Set<K>
keySet()
V
put(K key, V value)
Puts into the underlyingV
putIfAbsent(K key, V value)
Puts into the underlyingV
remove(K key)
Remove from the underlyingjava.lang.String
toString()
-
-
-
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:
toString
in 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
null
if there was no mapping for the key. (Anull
return can also indicate that the map previously associatednull
with 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
null
if 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)
-
-