java.util.Map 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.
This class has been copied as is from https://github.com/raphw/weak-lock-free/blob/ad0e5e0c04d4a31f9485bf12b89afbc9d75473b3/src/main/java/com/blogspot/mydailyjava/weaklockfree/WeakConcurrentMap.java
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| public static class | WeakConcurrentMap.
A |
| Modifier and Type | Field and Description |
|---|---|
| private static final AtomicLong | |
| private static final ThreadLocal | LOOKUP_KEY_CACHE
Lookup keys are cached thread-locally to avoid allocations on lookups. |
| private final boolean | |
| private final Thread |
| Access | Constructor and Description |
|---|---|
| public | WeakConcurrentMap(boolean
true if a thread should be started that removes stale entries.
|
| public | WeakConcurrentMap(boolean
true if a thread should be started that removes stale entries.true if the lookup keys should be reused via a ThreadLocal.
Note that setting this to true may result in class loader leaks. See isPersistentClassLoader(ClassLoader) for more details.
|
| public | WeakConcurrentMap(boolean
true if a thread should be started that removes stale entries.true if the lookup keys should be reused via a ThreadLocal.
Note that setting this to true may result in class loader leaks. See isPersistentClassLoader(ClassLoader) for more details.ConcurrentMap implementation that this class wraps. target
|
| Modifier and Type | Method and Description |
|---|---|
| public Thread | |
| protected WeakConcurrentMap. | getLookupKey(K key)
Implements abstract io. Override with care as it can cause lookup failures if done incorrectly. |
| private static boolean | Returns: true if the provided class loader can be unloaded.The class loader to check. classLoader)Checks whether the provided |
| protected void | resetLookupKey(WeakConcurrentMap.
Implements abstract io. Resets any reusable state in the lookup key. |
| ID | back to summary |
|---|---|
| private static final AtomicLong ID | |
| LOOKUP_KEY_CACHE | back to summary |
|---|---|
| private static final ThreadLocal<WeakConcurrentMap. Lookup keys are cached thread-locally to avoid allocations on lookups. This is beneficial as
the JIT unfortunately can't reliably replace the | |
| reuseKeys | back to summary |
|---|---|
| private final boolean reuseKeys | |
| thread | back to summary |
|---|---|
| private final Thread thread | |
| WeakConcurrentMap | back to summary |
|---|---|
public WeakConcurrentMap(boolean cleanerThread)
| |
| WeakConcurrentMap | back to summary |
|---|---|
public WeakConcurrentMap(boolean cleanerThread, boolean reuseKeys)
| |
| WeakConcurrentMap | back to summary |
|---|---|
public WeakConcurrentMap(boolean cleanerThread, boolean reuseKeys, ConcurrentMap<AbstractWeakConcurrentMap.
| |
| getCleanerThread | back to summary |
|---|---|
public Thread getCleanerThread()
| |
| getLookupKey | back to summary |
|---|---|
| protected WeakConcurrentMap. Implements abstract io. Doc from io. Override with care as it can cause lookup failures if done incorrectly. The result must have
the same
| |
| isPersistentClassLoader | back to summary |
|---|---|
| private static boolean isPersistentClassLoader(ClassLoader classLoader) Checks whether the provided If the class loader can't be unloaded, it is safe to use
| |
| resetLookupKey | back to summary |
|---|---|
| protected void resetLookupKey(WeakConcurrentMap. Implements abstract io. Doc from io. Resets any reusable state in the lookup key.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. Indicates whether some other object is "equal to" this one. |
| public int | |
| pack-priv void | |
| pack-priv WeakConcurrentMap. |
| LookupKey | back to summary |
|---|---|
| pack-priv LookupKey() | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| reset | back to summary |
|---|---|
| pack-priv void reset() Failing to reset a lookup key can lead to memory leaks as the key is strongly referenced. | |
| withValue | back to summary |
|---|---|
| pack-priv WeakConcurrentMap. | |
WeakConcurrentMap where stale entries are removed as a side effect of interacting
with this map.
| Access | Constructor and Description |
|---|---|
| public |
| WithInlinedExpunction | back to summary |
|---|---|
| public WithInlinedExpunction() | |
| approximateSize | back to summary |
|---|---|
| public int approximateSize() Overrides io. Doc from io. Returns the approximate size of this map where the returned number is at least as big as the actual number of entries.
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(K key) Overrides io.
| |
| get | back to summary |
|---|---|
| public V get(K key) Overrides io.
| |
| iterator | back to summary |
|---|---|
| public Iterator Overrides io. Implements java. Doc from java. Returns an iterator over elements of type | |
| put | back to summary |
|---|---|
| public V put(K key, V value) Overrides io.
| |
| remove | back to summary |
|---|---|
| public V remove(K key) Overrides io.
| |