Introduction to jctools

JCTools

As early as 1996, some papers put forward the concept of lockless queue. Later, the high performance of destroyer has been verified by production. The performance of the high-performance queues in jctools described here is no worse than that of the disruptor.

Jctools (Java concurrency tools) provides a series of non blocking concurrent data structures (missing in standard Java). When there is thread contention, non blocking concurrent data structures can provide better performance than blocking concurrent data structures.

Jctools is an open source toolkit, released under Apache license 2.0, and widely used in many frameworks such as netty and rxjava.

Open source GitHub repository for jctools: https://github.com/JCTools/JCTools

You can use jctools by introducing the jctools jar package into Maven:

        <dependency>
            <groupId>org.jctools</groupId>
            <artifactId>jctools-core</artifactId>
            <version>3.0.0</version>
        </dependency>

Jctools mainly provides non blocking concurrent data structures of map and queue:

Non blocking map

Nonblocking HashMap is an enhancement to concurrent HashMap, which provides better performance for multi CPU support and high concurrent updates.

Nonblockinghashmaplong is a nonblockinghashmap whose key is long.

Nonblockinghashset is a simple wrapper for nonblockinghashmap to support the interface of set.

Nonblockingidentityhashmap is transformed from nonblockinghashmap and uses system Identityhashcode() to calculate the hash.

Nonblocking setint is a simple bit vector using CAS.

Non blocking queue

The non blocking queues provided by jctools are divided into four categories, which can be selected according to different application scenarios:

"Producer" and "consumer" refer to "production thread" and "consumption thread".

        // spsc-有界/无界队列
        Queue<String> spscArrayQueue = new SpscArrayQueue(16);
        Queue<String> spscUnboundedArrayQueue = new SpscUnboundedArrayQueue(2);
        // spmc-有界队列
        Queue<String> spmcArrayQueue = new SpmcArrayQueue<>(16);
        // mpsc-有界/无界队列
        Queue<String> mpscArrayQueue = new MpscArrayQueue<>(16);
        Queue<String> mpscChunkedArrayQueue = new MpscChunkedArrayQueue<>(1024,8 * 1024);
        Queue<String> mpscUnboundedArrayQueue = new MpscUnboundedArrayQueue<>(2);
        // mpmc-有界队列
        Queue<String> mpmcArrayQueue = new MpmcArrayQueue<>(16);

http://tutorials.jenkov.com/jctools/index.html

https://segmentfault.com/a/1190000011009097

https://blog.csdn.net/TheLudlows/article/details/90646236

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>