public abstract class AbstractByteBufPool<T> extends Object
<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.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_POOL_CAPACITY |
Constructor and Description |
---|
AbstractByteBufPool() |
AbstractByteBufPool(int capacity) |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
canPool(io.netty.buffer.ByteBuf byteBuf,
int length)
Returns
true if length 's byteBuf content from ByteBuf.readerIndex() can be pooled,
false otherwise. |
protected abstract T |
create(io.netty.buffer.ByteBuf byteBuf,
int length)
Create a new entry.
|
T |
getOrCreate(io.netty.buffer.ByteBuf byteBuf)
Returns a pooled entry if possible, a new one otherwise.
|
protected abstract boolean |
isEqual(T entry,
io.netty.buffer.ByteBuf byteBuf,
int offset,
int length)
Returns
true if the entry content is the same of byteBuf at the specified offset
and length false otherwise. |
public static final int DEFAULT_POOL_CAPACITY
public AbstractByteBufPool()
public AbstractByteBufPool(int capacity)
protected abstract boolean canPool(io.netty.buffer.ByteBuf byteBuf, int length)
true
if length
's byteBuf
content from ByteBuf.readerIndex()
can be pooled,
false
otherwise.protected abstract T create(io.netty.buffer.ByteBuf byteBuf, int length)
protected abstract boolean isEqual(T entry, io.netty.buffer.ByteBuf byteBuf, int offset, int length)
true
if the entry
content is the same of byteBuf
at the specified offset
and length
false
otherwise.public final T getOrCreate(io.netty.buffer.ByteBuf byteBuf)
The byteBuf
's ByteBuf.readerIndex()
is incremented by length
after it.
Copyright © 2018 JBoss by Red Hat. All rights reserved.