Class AbstractByteBufPool<T>
- java.lang.Object
-
- org.apache.activemq.artemis.utils.AbstractByteBufPool<T>
-
- Direct Known Subclasses:
SimpleString.ByteBufSimpleStringPool,TypedProperties.StringValue.ByteBufStringValuePool
public abstract class AbstractByteBufPool<T> extends java.lang.ObjectThread-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 Modifier and Type Field Description static intDEFAULT_POOL_CAPACITY
-
Constructor Summary
Constructors Constructor Description AbstractByteBufPool()AbstractByteBufPool(int capacity)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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.TgetOrCreate(io.netty.buffer.ByteBuf byteBuf)Returns a pooled entry if possible, a new one otherwise.protected abstract booleanisEqual(T entry, io.netty.buffer.ByteBuf byteBuf, int offset, int length)Returnstrueif theentrycontent is the same ofbyteBufat the specifiedoffsetandlengthfalseotherwise.
-
-
-
Field Detail
-
DEFAULT_POOL_CAPACITY
public static final int DEFAULT_POOL_CAPACITY
- See Also:
- Constant Field Values
-
-
Method Detail
-
canPool
protected abstract boolean canPool(io.netty.buffer.ByteBuf byteBuf, int length)Returnstrueiflength'sbyteBufcontent fromByteBuf.readerIndex()can be pooled,falseotherwise.
-
create
protected abstract T create(io.netty.buffer.ByteBuf byteBuf, int length)
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.
-
getOrCreate
public final T getOrCreate(io.netty.buffer.ByteBuf byteBuf)
Returns a pooled entry if possible, a new one otherwise.The
byteBuf'sByteBuf.readerIndex()is incremented bylengthafter it.
-
-