drain() — netty Function Reference
Architecture documentation for the drain() function in MpscIntQueue.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a6577b96_ac1f_02a7_4a84_eb562e174042["drain()"] c00a7e8d_e19a_6d4a_6887_5d0634281bed["MpscAtomicIntegerArrayQueue"] a6577b96_ac1f_02a7_4a84_eb562e174042 -->|defined in| c00a7e8d_e19a_6d4a_6887_5d0634281bed 16657c3a_e2e7_fd92_b734_85f139e981e7["size()"] a6577b96_ac1f_02a7_4a84_eb562e174042 -->|calls| 16657c3a_e2e7_fd92_b734_85f139e981e7 style a6577b96_ac1f_02a7_4a84_eb562e174042 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/MpscIntQueue.java lines 185–207
@Override
public int drain(int limit, IntConsumer consumer) {
Objects.requireNonNull(consumer, "consumer");
ObjectUtil.checkPositiveOrZero(limit, "limit");
if (limit == 0) {
return 0;
}
final int mask = this.mask;
final long cIndex = consumerIndex; // Note: could be weakened to plain-load.
for (int i = 0; i < limit; i++) {
final long index = cIndex + i;
final int offset = (int) (index & mask);
final int value = get(offset);
if (emptyValue == value) {
return i;
}
lazySet(offset, emptyValue); // Note: could be weakened to plain-store.
// ordered store -> atomic and ordered for size()
CONSUMER_INDEX.lazySet(this, index + 1);
consumer.accept(value);
}
return limit;
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does drain() do?
drain() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/MpscIntQueue.java.
Where is drain() defined?
drain() is defined in common/src/main/java/io/netty/util/concurrent/MpscIntQueue.java at line 185.
What does drain() call?
drain() calls 1 function(s): size.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free