Class AbstractByteBufPool<T>
java.lang.Object
org.apache.activemq.artemis.utils.AbstractByteBufPool<T>
- Direct Known Subclasses:
SimpleString.ByteBufSimpleStringPool,TypedProperties.StringValue.ByteBufStringValuePool
Thread-safe
<T> interner.
Differently from String.intern() it contains a fixed amount of entries and when used by concurrent threads it
doesn't ensure the uniqueness of the entries ie the same entry could be allocated multiple times by concurrent
calls.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancanPool(io.netty.buffer.ByteBuf byteBuf, int length) Returnstrueiflength'sbyteBufcontent fromByteBuf.readerIndex()can be pooled,falseotherwise.protected abstract Tcreate(io.netty.buffer.ByteBuf byteBuf, int length) Create a new entry.final TgetOrCreate(io.netty.buffer.ByteBuf byteBuf) Returns a pooled entry if possible, a new one otherwise.protected abstract booleanReturnstrueif theentrycontent is the same ofbyteBufat the specifiedoffsetandlengthfalseotherwise.
-
Field Details
-
DEFAULT_POOL_CAPACITY
public static final int DEFAULT_POOL_CAPACITY- See Also:
-
-
Constructor Details
-
AbstractByteBufPool
public AbstractByteBufPool() -
AbstractByteBufPool
public AbstractByteBufPool(int capacity)
-
-
Method Details
-
canPool
protected abstract boolean canPool(io.netty.buffer.ByteBuf byteBuf, int length) Returnstrueiflength'sbyteBufcontent fromByteBuf.readerIndex()can be pooled,falseotherwise.- Returns:
trueiflength'sbyteBufcontent fromByteBuf.readerIndex()can be pooled,falseotherwise
-
create
Create a new entry. -
isEqual
protected abstract boolean isEqual(T entry, io.netty.buffer.ByteBuf byteBuf, int offset, int length) Returnstrueif theentrycontent is the same ofbyteBufat the specifiedoffsetandlengthfalseotherwise.- Returns:
trueif theentrycontent is the same ofbyteBufat the specifiedoffsetandlengthfalseotherwise
-
getOrCreate
Returns a pooled entry if possible, a new one otherwise.The
byteBuf'sByteBuf.readerIndex()is incremented bylengthafter it.
-