CodecOutputList Class — netty Architecture
Architecture documentation for the CodecOutputList class in CodecOutputList.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 6ac16422_9a27_c4b7_2cbb_da7b639a19f5["CodecOutputList"] 71209b4a_e4d1_da5a_9c59_6396227fc322["CodecOutputList.java"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|defined in| 71209b4a_e4d1_da5a_9c59_6396227fc322 47f77125_cf0c_c97c_a8ce_e9db32962a7a["CodecOutputList()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| 47f77125_cf0c_c97c_a8ce_e9db32962a7a 5358d6ac_3cd6_0f25_d42d_cbeb38d29ed6["Object()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| 5358d6ac_3cd6_0f25_d42d_cbeb38d29ed6 94ba2718_9506_4612_ea98_da6eb68e3f7c["size()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| 94ba2718_9506_4612_ea98_da6eb68e3f7c c2d77e60_10a0_d3f8_12aa_831ad0030005["add()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| c2d77e60_10a0_d3f8_12aa_831ad0030005 5ea1ec7e_869d_ee91_c764_3af6912572f4["clear()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| 5ea1ec7e_869d_ee91_c764_3af6912572f4 f31efe93_6bfc_eada_966b_3718e42dbc88["insertSinceRecycled()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| f31efe93_6bfc_eada_966b_3718e42dbc88 9f73e4d1_da2f_d15c_fb55_a52468f21f2c["recycle()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| 9f73e4d1_da2f_d15c_fb55_a52468f21f2c 4e5d9039_6b7f_1bb0_324e_e9da116b7ae7["checkIndex()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| 4e5d9039_6b7f_1bb0_324e_e9da116b7ae7 e69df763_3aef_2f09_e4d5_2bed76d725fc["insert()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| e69df763_3aef_2f09_e4d5_2bed76d725fc cc7605e3_5eb4_3474_a434_165576d90234["expandArray()"] 6ac16422_9a27_c4b7_2cbb_da7b639a19f5 -->|method| cc7605e3_5eb4_3474_a434_165576d90234
Relationship Graph
Source Code
codec-base/src/main/java/io/netty/handler/codec/CodecOutputList.java lines 29–236
final class CodecOutputList extends AbstractList<Object> implements RandomAccess {
private static final CodecOutputListRecycler NOOP_RECYCLER = new CodecOutputListRecycler() {
@Override
public void recycle(CodecOutputList object) {
// drop on the floor and let the GC handle it.
}
};
private static final FastThreadLocal<CodecOutputLists> CODEC_OUTPUT_LISTS_POOL =
new FastThreadLocal<CodecOutputLists>() {
@Override
protected CodecOutputLists initialValue() throws Exception {
// 16 CodecOutputList per Thread are cached.
return new CodecOutputLists(16);
}
};
private interface CodecOutputListRecycler {
void recycle(CodecOutputList codecOutputList);
}
private static final class CodecOutputLists implements CodecOutputListRecycler {
private final CodecOutputList[] elements;
private final int mask;
private int currentIdx;
private int count;
CodecOutputLists(int numElements) {
elements = new CodecOutputList[MathUtil.safeFindNextPositivePowerOfTwo(numElements)];
for (int i = 0; i < elements.length; ++i) {
// Size of 16 should be good enough for the majority of all users as an initial capacity.
elements[i] = new CodecOutputList(this, 16);
}
count = elements.length;
currentIdx = elements.length;
mask = elements.length - 1;
}
public CodecOutputList getOrCreate() {
if (count == 0) {
// Return a new CodecOutputList which will not be cached. We use a size of 4 to keep the overhead
// low.
return new CodecOutputList(NOOP_RECYCLER, 4);
}
--count;
int idx = (currentIdx - 1) & mask;
CodecOutputList list = elements[idx];
currentIdx = idx;
return list;
}
@Override
public void recycle(CodecOutputList codecOutputList) {
int idx = currentIdx;
elements[idx] = codecOutputList;
currentIdx = (idx + 1) & mask;
++count;
assert count <= elements.length;
}
}
static CodecOutputList newInstance() {
return CODEC_OUTPUT_LISTS_POOL.get().getOrCreate();
}
private final CodecOutputListRecycler recycler;
private int size;
private int maxSeenSize;
private Object[] array;
private boolean insertSinceRecycled;
private CodecOutputList(CodecOutputListRecycler recycler, int size) {
this.recycler = recycler;
array = new Object[size];
}
@Override
public Object get(int index) {
Source
Frequently Asked Questions
What is the CodecOutputList class?
CodecOutputList is a class in the netty codebase, defined in codec-base/src/main/java/io/netty/handler/codec/CodecOutputList.java.
Where is CodecOutputList defined?
CodecOutputList is defined in codec-base/src/main/java/io/netty/handler/codec/CodecOutputList.java at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free