8000 GitHub - trivago/fastutil-concurrent-wrapper at v0.1.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

trivago/fastutil-concurrent-wrapper

Repository files navigation

FastUtil Concurrent Wrapper

Java CI Maven Central

Description

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 of synchronized(mutex); one RW-lock per map's bucket,
  • two lock modes: standard and busy-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.

Install

Maven

<dependency>
    <groupId>com.trivago</groupId>
    <artifactId>fastutil-concurrent-wrapper</artifactId>
    <version>0.0.1</version>
</dependency>

Gradle

implementation group: 'com.trivago', name: 'fastutil-concurrent-wrapper', version: '0.0.1'

Usage

Builder options

  • number of buckets -- number of buckets in the map (default 8),
  • default value -- default value, for getOrDefault() method
  • initial capacity -- initial map capacity (default 100_000),
  • concurrent mode -- lock mode: default and busy-waiting,
  • load factor -- map load factor (default 0.8f).

Basic usage

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;

MapMode

Currently, we offer two locking modes:

  • blocking (default),
  • busy-waiting.

Maintainers

A-Z surname order

0