std.collection.concurrent

Overview

The collection.concurrent package provides concurrency-safe collection types.

This package implements the following concurrency-safe collection types:

  • ArrayBlockingQueue: bounded queue of a fixed size, which is implemented in the form of arrays

  • ConcurrentHashMap: thread-safe hash table implementation, which supports high-concurrency read and write operations

  • ConcurrentLinkedQueue: thread-safe queue data structure (When an element is added, if the number of elements in the last block reaches the maximum, a new block is created. In this way, the element addition is not blocked. Therefore, in a multi-thread environment, thread blocking caused by blocked operations on the queue can be prevented, thereby improving program performance.)

  • LinkedBlockingQueue: blocking queue, which supports blocking element obtaining when the queue is empty and blocking element addition when the queue is full

API List

Type Alias

NameDescription
BlockingQueue<E> (deprecated)Specifies the alias of LinkedBlockingQueue.
NonBlockingQueue<E> (deprecated)Specifies the alias of ConcurrentLinkedQueue.

Interface

NameDescription
ConcurrentMap<K, V>Guarantees thread security and operation atomicity.

Class

NameDescription
ArrayBlockingQueue<E>Implements the Blocking Queue data structure and related operation functions based on arrays.
ConcurrentHashMapIterator<K, V> where K <: Hashable & Equatable<K>Implements the iterator functionality of ConcurrentHashMap.
ConcurrentHashMap<K, V> where K <: Hashable & Equatable<K>Implements the data structure and related operation functions of the thread-safe hash table ConcurrentHashMap in concurrency scenarios.
ConcurrentLinkedQueue<E>Provides thread-safe queues to safely add and delete elements in a multi-thread environment.
LinkedBlockingQueue<E>Implements a concurrent queue with a blocking mechanism, which supports users to specify the upper limit of capacity.