fill() — netty Function Reference
Architecture documentation for the fill() function in MpscIntQueue.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c1dd1383_c80c_804d_7edd_027316763c11["fill()"] c00a7e8d_e19a_6d4a_6887_5d0634281bed["MpscAtomicIntegerArrayQueue"] c1dd1383_c80c_804d_7edd_027316763c11 -->|defined in| c00a7e8d_e19a_6d4a_6887_5d0634281bed style c1dd1383_c80c_804d_7edd_027316763c11 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/MpscIntQueue.java lines 209–245
@Override
public int fill(int limit, IntSupplier supplier) {
Objects.requireNonNull(supplier, "supplier");
ObjectUtil.checkPositiveOrZero(limit, "limit");
if (limit == 0) {
return 0;
}
final int mask = this.mask;
final long capacity = mask + 1;
long producerLimit = this.producerLimit;
long pIndex;
int actualLimit;
do {
pIndex = producerIndex;
long available = producerLimit - pIndex;
if (available <= 0) {
final long cIndex = consumerIndex;
producerLimit = cIndex + capacity;
available = producerLimit - pIndex;
if (available <= 0) {
// FULL :(
return 0;
} else {
// update producer limit to the next index that we must recheck the consumer index
PRODUCER_LIMIT.lazySet(this, producerLimit);
}
}
actualLimit = Math.min((int) available, limit);
} while (!PRODUCER_INDEX.compareAndSet(this, pIndex, pIndex + actualLimit));
// right, now we claimed a few slots and can fill them with goodness
for (int i = 0; i < actualLimit; i++) {
// Won CAS, move on to storing
final int offset = (int) (pIndex + i & mask);
lazySet(offset, supplier.getAsInt());
}
return actualLimit;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does fill() do?
fill() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/MpscIntQueue.java.
Where is fill() defined?
fill() is defined in common/src/main/java/io/netty/util/concurrent/MpscIntQueue.java at line 209.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free