java.lang.Object
java.lang.ref.ReferenceQueue<K>
com.tlcsdm.core.concurrent.AbstractWeakConcurrentMap<K,V,WeakConcurrentMap.LookupKey<K>>
com.tlcsdm.core.concurrent.WeakConcurrentMap<K,V>
public class WeakConcurrentMap<K,V>
extends AbstractWeakConcurrentMap<K,V,WeakConcurrentMap.LookupKey<K>>
A thread-safe map with weak keys. Entries are based on a key's system hash code and keys are considered equal only by reference equality.
This class does not implement theMap interface because this implementation is incompatible
with the map contract. While iterating over a map's entries, any key that has not passed iteration is referenced non-weakly.- 作者:
- unknowIfGuestInDream
-
嵌套类概要
嵌套类修饰符和类型类说明(专用程序包) static final classstatic classAWeakConcurrentMapwhere stale entries are removed as a side effect of interacting with this map.从类继承的嵌套类/接口 com.tlcsdm.core.concurrent.AbstractWeakConcurrentMap
AbstractWeakConcurrentMap.WeakKey<K> -
字段概要
字段修饰符和类型字段说明private static final AtomicLongprivate static final ThreadLocal<WeakConcurrentMap.LookupKey<?>> Lookup keys are cached thread-locally to avoid allocations on lookups.private final booleanprivate final Thread从类继承的字段 com.tlcsdm.core.concurrent.AbstractWeakConcurrentMap
target -
构造器概要
构造器构造器说明WeakConcurrentMap(boolean cleanerThread) WeakConcurrentMap(boolean cleanerThread, boolean reuseKeys) WeakConcurrentMap(boolean cleanerThread, boolean reuseKeys, ConcurrentMap<AbstractWeakConcurrentMap.WeakKey<K>, V> target) -
方法概要
修饰符和类型方法说明protected WeakConcurrentMap.LookupKey<K> getLookupKey(K key) Override with care as it can cause lookup failures if done incorrectly.private static booleanisPersistentClassLoader(ClassLoader classLoader) Checks whether the providedClassLoadermay be unloaded like a web application class loader, for example.protected voidresetLookupKey(WeakConcurrentMap.LookupKey<K> lookupKey) Resets any reusable state in the lookup key.从类继承的方法 com.tlcsdm.core.concurrent.AbstractWeakConcurrentMap
approximateSize, clear, containsKey, defaultValue, expungeStaleEntries, get, getIfPresent, iterator, put, putIfAbsent, putIfProbablyAbsent, remove, run, toString从类继承的方法 java.lang.ref.ReferenceQueue
poll, remove, remove从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 java.lang.Iterable
forEach, spliterator
-
字段详细资料
-
LOOKUP_KEY_CACHE
Lookup keys are cached thread-locally to avoid allocations on lookups. This is beneficial as the JIT unfortunately can't reliably replace theWeakConcurrentMap.LookupKeyallocation with stack allocations, even though theWeakConcurrentMap.LookupKeydoes not escape. -
ID
-
thread
-
reuseKeys
private final boolean reuseKeys
-
-
构造器详细资料
-
WeakConcurrentMap
public WeakConcurrentMap(boolean cleanerThread) - 参数:
cleanerThread-trueif a thread should be started that removes stale entries.
-
WeakConcurrentMap
public WeakConcurrentMap(boolean cleanerThread, boolean reuseKeys) - 参数:
cleanerThread-trueif a thread should be started that removes stale entries.reuseKeys-trueif the lookup keys should be reused via aThreadLocal. Note that setting this totruemay result in class loader leaks. SeeisPersistentClassLoader(ClassLoader)for more details.
-
WeakConcurrentMap
public WeakConcurrentMap(boolean cleanerThread, boolean reuseKeys, ConcurrentMap<AbstractWeakConcurrentMap.WeakKey<K>, V> target) - 参数:
cleanerThread-trueif a thread should be started that removes stale entries.reuseKeys-trueif the lookup keys should be reused via aThreadLocal. Note that setting this totruemay result in class loader leaks. SeeisPersistentClassLoader(ClassLoader)for more details.target- ConcurrentMap implementation that this class wraps.
-
-
方法详细资料
-
isPersistentClassLoader
Checks whether the providedClassLoadermay be unloaded like a web application class loader, for example.If the class loader can't be unloaded, it is safe to use
ThreadLocals and to reuse theWeakConcurrentMap.LookupKey. Otherwise, the use ofThreadLocals may lead to class loader leaks as it prevents the class loader this class is loaded by to unload.- 参数:
classLoader- The class loader to check.- 返回:
trueif the provided class loader can be unloaded.
-
getLookupKey
从类复制的说明:AbstractWeakConcurrentMapOverride with care as it can cause lookup failures if done incorrectly. The result must have the sameObject.hashCode()as the input and beequal toa weak reference of the key. When overriding this, also overrideAbstractWeakConcurrentMap.resetLookupKey(L). -
resetLookupKey
从类复制的说明:AbstractWeakConcurrentMapResets any reusable state in the lookup key. -
getCleanerThread
- 返回:
- The cleaner thread or
nullif no such thread was set.
-