Set of concurrent wrappers around fastutil primitive maps.
Main purpose is to provide useful concurrent builders around fastutil primitive maps with flexible locking policy.
Advantages over java.util wrappers:
- builders provide maps with buckets,
- every map uses
striped ReadWriteLocks
instead ofsynchronized(mutex)
; one RW-lock per map's bucket, - two lock modes:
standard
andbusy-waiting
(could be good for low-latency systems), - no extra memory on stack -- API based on
primitive types
.
Check usage section for more details.
Note: currently the lib contains wrappers not for every primitive map. Feel free to contribute.
<dependency>
<groupId>com.trivago</groupId>
<artifactId>fastutil-concurrent-wrapper</artifactId>
<version>0.0.1</version>
</dependency>
implementation group: 'com.trivago', name: 'fastutil-concurrent-wrapper', version: '0.0.1'
number of buckets
-- number of buckets in the map (default8
),default value
-- default value, for getOrDefault() methodinitial capacity
-- initial map capacity (default100_000
),concurrent mode
-- lock mode: default and busy-waiting,load factor
-- map load factor (default0.8f
).
ConcurrentLongLongMapBuilder b = ConcurrentLongLongMapBuilder.newBuilder()
.withBuckets(2)
.withDefaultValue(0)
.withInitialCapacity(100)
.withMode(ConcurrentLongLongMapBuilder.MapMode.BUSY_WAITING)
.withLoadFactor(0.9f);
LongLongMap map = b.build();
map.put(1L, 10L);
long v = map.get(1L);
Examples of creation and usage could be found inside test directory;
Currently, we offer two locking modes:
blocking
(default),busy-waiting
.
A-Z surname order