Implementation of a concurrent map with weak keys and a detached thread local storage.
Java
121
99 commits
updated Nov 20, 2024
This is a miniature implementation of a concurrent, lock-free (as in lock-less) hash map with weak keys where keys respect reference equality. Such a hash map removes entries containing collected keys by either:
As a wrapper around this WeakConcurrentMap, this package also contains a DetachedThreadLocal which describes a weak concurrent map where the current thread serves as a key of the map. Also, this package delivers a WeakConcurrentSet as a wrapper around a weak concurrent map.
This map does not implement the java.util.Map interface to simplify the implementation. Writes to the map might cause blocking if many threads write to the map concurrently (this is implied by the maps backing by a ConcurrentHashMap and a ReferenceQueue), the performance of the map is however significantly better than using a synchronized wrapper around a weak hash map.
The library is hosted on Maven Central and JCenter:
<dependency>
<groupId>com.blogspot.mydailyjava</groupId>
<artifactId>weak-lock-free</artifactId>
<version>LATEST</version>
</dependency>
284 followers · starred Aug 2019
144 followers · starred Apr 2020
165 followers · starred Jul 2022
32 followers · starred Aug 2022
Java
100.0%
Implementation of a concurrent map with weak keys and a detached thread local storage.
Java
121
99 commits
updated Nov 20, 2024
This is a miniature implementation of a concurrent, lock-free (as in lock-less) hash map with weak keys where keys respect reference equality. Such a hash map removes entries containing collected keys by either:
As a wrapper around this WeakConcurrentMap, this package also contains a DetachedThreadLocal which describes a weak concurrent map where the current thread serves as a key of the map. Also, this package delivers a WeakConcurrentSet as a wrapper around a weak concurrent map.
This map does not implement the java.util.Map interface to simplify the implementation. Writes to the map might cause blocking if many threads write to the map concurrently (this is implied by the maps backing by a ConcurrentHashMap and a ReferenceQueue), the performance of the map is however significantly better than using a synchronized wrapper around a weak hash map.
The library is hosted on Maven Central and JCenter:
<dependency>
<groupId>com.blogspot.mydailyjava</groupId>
<artifactId>weak-lock-free</artifactId>
<version>LATEST</version>
</dependency>
284 followers · starred Aug 2019
144 followers · starred Apr 2020
165 followers · starred Jul 2022
32 followers · starred Aug 2022
Java
100.0%