Class WeakConcurrentMap<K,​V>

  • All Implemented Interfaces:
    java.lang.Iterable<java.util.Map.Entry<K,​V>>, java.lang.Runnable
    Direct Known Subclasses:
    StrictContextStorage.PendingScopes, WeakConcurrentMap.WithInlinedExpunction

    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 the 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.

    • Field Detail

      • ID

        private static final java.util.concurrent.atomic.AtomicLong ID
      • thread

        private final java.lang.Thread thread
      • reuseKeys

        private final boolean reuseKeys
    • Constructor Detail

      • WeakConcurrentMap

        public WeakConcurrentMap​(boolean cleanerThread)
        Parameters:
        cleanerThread - true if a thread should be started that removes stale entries.
      • WeakConcurrentMap

        public WeakConcurrentMap​(boolean cleanerThread,
                                 boolean reuseKeys)
        Parameters:
        cleanerThread - true if a thread should be started that removes stale entries.
        reuseKeys - 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.
      • WeakConcurrentMap

        public WeakConcurrentMap​(boolean cleanerThread,
                                 boolean reuseKeys,
                                 java.util.concurrent.ConcurrentMap<AbstractWeakConcurrentMap.WeakKey<K>,​V> target)
        Parameters:
        cleanerThread - true if a thread should be started that removes stale entries.
        reuseKeys - 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.
        target - ConcurrentMap implementation that this class wraps.