Mpsc Class — netty Architecture
Architecture documentation for the Mpsc class in PlatformDependent.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 64a7fae9_2520_5d33_c8bb_078ffd09ede3["Mpsc"] 2a0673d5_1a45_ed74_0c46_7c4c3869c36d["PlatformDependent.java"] 64a7fae9_2520_5d33_c8bb_078ffd09ede3 -->|defined in| 2a0673d5_1a45_ed74_0c46_7c4c3869c36d 2959ba5c_232d_fa19_0dd5_61352fd9a44f["newMpscQueue()"] 64a7fae9_2520_5d33_c8bb_078ffd09ede3 -->|method| 2959ba5c_232d_fa19_0dd5_61352fd9a44f 2c56bdf1_39e8_a02b_7bb7_2e17c47dfe88["newChunkedMpscQueue()"] 64a7fae9_2520_5d33_c8bb_078ffd09ede3 -->|method| 2c56bdf1_39e8_a02b_7bb7_2e17c47dfe88
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/PlatformDependent.java lines 1236–1280
private static final class Mpsc {
private static final boolean USE_MPSC_CHUNKED_ARRAY_QUEUE;
static {
Object unsafe = null;
if (hasUnsafe()) {
// jctools goes through its own process of initializing unsafe; of
// course, this requires permissions which might not be granted to calling code, so we
// must mark this block as privileged too
unsafe = AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
// force JCTools to initialize unsafe
return UnsafeAccess.UNSAFE;
}
});
}
if (unsafe == null) {
logger.debug("org.jctools-core.MpscChunkedArrayQueue: unavailable");
USE_MPSC_CHUNKED_ARRAY_QUEUE = false;
} else {
logger.debug("org.jctools-core.MpscChunkedArrayQueue: available");
USE_MPSC_CHUNKED_ARRAY_QUEUE = true;
}
}
static <T> Queue<T> newMpscQueue(final int maxCapacity) {
// Calculate the max capacity which can not be bigger than MAX_ALLOWED_MPSC_CAPACITY.
// This is forced by the MpscChunkedArrayQueue implementation as will try to round it
// up to the next power of two and so will overflow otherwise.
final int capacity = max(min(maxCapacity, MAX_ALLOWED_MPSC_CAPACITY), MIN_MAX_MPSC_CAPACITY);
return newChunkedMpscQueue(MPSC_CHUNK_SIZE, capacity);
}
static <T> Queue<T> newChunkedMpscQueue(final int chunkSize, final int capacity) {
return USE_MPSC_CHUNKED_ARRAY_QUEUE ? new MpscChunkedArrayQueue<T>(chunkSize, capacity)
: new MpscChunkedAtomicArrayQueue<T>(chunkSize, capacity);
}
static <T> Queue<T> newMpscQueue() {
return USE_MPSC_CHUNKED_ARRAY_QUEUE ? new MpscUnboundedArrayQueue<T>(MPSC_CHUNK_SIZE)
: new MpscUnboundedAtomicArrayQueue<T>(MPSC_CHUNK_SIZE);
}
}
Source
Frequently Asked Questions
What is the Mpsc class?
Mpsc is a class in the netty codebase, defined in common/src/main/java/io/netty/util/internal/PlatformDependent.java.
Where is Mpsc defined?
Mpsc is defined in common/src/main/java/io/netty/util/internal/PlatformDependent.java at line 1236.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free